Trouble passing datetime parameter to web service, in GET

GVillani82

I created a web service using ASP .NET Web API. The method is:

    [HttpGet]
    [Route("service/{applicantUser}/{lastUpdate:datetime?}")]
    public IHttpActionResult getService(String applicantUser, DateTime? lastUpdate = null){
    // some stuff here

 }

If I call the WS in this way:

http://myserver/api/service/myusername/2008-12-10

all works good, and I obtain a correct json file. But if I try to add the time:

http://myserver/api/service/myusername/2008-12-10T12:30:00

I obtain the error 404 - Bad Request

DavidG

The problem is with the colon (:) character in the URL which is not allowed. You can either put the parameter in the query string:

http://myserver/api/service/myusername/?lastUpdate=2008-12-10T12:30:00

Or disable the validation to check for potentially dangerous request paths by merging this to your web.config:

<system.web>
    <httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />
    <pages validateRequest="false" />
</system.web>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Web Service Passing parameter Class

From Dev

JAVA: Restfull web service not passing parameter correctly

From Dev

JAVA: Restfull web service not passing parameter correctly

From Dev

Passing a file as a parameter for a Spring web service via Postman

From Dev

Call ASMX web service with parameter and get value from that web service?

From Dev

passing parameter in wcf service through get method not working

From Dev

Passing multiple Id parameter to Web Api GET or DELETE request

From Dev

Datetime expression in JPA by passing as parameter

From Dev

Angular2 Passing parameters to web service http GET

From Dev

Angular2 Passing parameters to web service http GET

From Dev

MultiValueDictKeyError - Passing GET parameter

From Dev

Passing a parameter to an ionic angular service

From Dev

Passing a parameter in url Restful service?

From Dev

Passing a parameter to an ionic angular service

From Dev

JSON Parameter for Web Service

From Dev

Passing date to ASMX web service

From Dev

Passing Username and Password to Web Service

From Dev

Passing a password to a web service and storing it

From Dev

passing string as datetime parameter in sql command

From Dev

Golang: Passing a URL as a GET parameter

From Dev

Passing $_POST/$_GET as a parameter to function

From Dev

Retrofit: passing multiple GET parameter

From Dev

Passing IEnumerable<int> as parameter to WCF service

From Dev

Delphi: Passing a parameter to a running service to act on

From Dev

$location service not passing URL Parameter to Controller

From Dev

ASP.NET Web API GET Method: Passing multiple values for single parameter

From Dev

How to get rid of passing "username and password" in web service call to Pentaho transformation?

From Dev

Passing POST parameter to WEB API2

From Dev

Passing parameter to a vaadin 7 web application

Related Related

  1. 1

    Web Service Passing parameter Class

  2. 2

    JAVA: Restfull web service not passing parameter correctly

  3. 3

    JAVA: Restfull web service not passing parameter correctly

  4. 4

    Passing a file as a parameter for a Spring web service via Postman

  5. 5

    Call ASMX web service with parameter and get value from that web service?

  6. 6

    passing parameter in wcf service through get method not working

  7. 7

    Passing multiple Id parameter to Web Api GET or DELETE request

  8. 8

    Datetime expression in JPA by passing as parameter

  9. 9

    Angular2 Passing parameters to web service http GET

  10. 10

    Angular2 Passing parameters to web service http GET

  11. 11

    MultiValueDictKeyError - Passing GET parameter

  12. 12

    Passing a parameter to an ionic angular service

  13. 13

    Passing a parameter in url Restful service?

  14. 14

    Passing a parameter to an ionic angular service

  15. 15

    JSON Parameter for Web Service

  16. 16

    Passing date to ASMX web service

  17. 17

    Passing Username and Password to Web Service

  18. 18

    Passing a password to a web service and storing it

  19. 19

    passing string as datetime parameter in sql command

  20. 20

    Golang: Passing a URL as a GET parameter

  21. 21

    Passing $_POST/$_GET as a parameter to function

  22. 22

    Retrofit: passing multiple GET parameter

  23. 23

    Passing IEnumerable<int> as parameter to WCF service

  24. 24

    Delphi: Passing a parameter to a running service to act on

  25. 25

    $location service not passing URL Parameter to Controller

  26. 26

    ASP.NET Web API GET Method: Passing multiple values for single parameter

  27. 27

    How to get rid of passing "username and password" in web service call to Pentaho transformation?

  28. 28

    Passing POST parameter to WEB API2

  29. 29

    Passing parameter to a vaadin 7 web application

HotTag

Archive