How to send datetime parameter to WCF REST service

I have a WCF data service service:

[WebGet] public bool isContractUpToDate(string contractId, string lastmodifiedDate); 

but I don’t know how to call this service from the .NET client application and how I can call this operation from Internet Explorer. I am looking for some examples.

+4
source share
5 answers

I finally found the answer to my question. to invoke the operation from the browser, I use:

  http://localhost:8080/service/ctrService.svc/isContractUpToDate?contractId='1'&lastmodifieddate='2012/02/04 00:00:00' 

and do it from a .NET client, I use:

  IEnumerable<bool> resp = service.Execute<bool>(new Uri("http://localhost:8080/pricingservice/PricingDataService.svc/isContractUpToDate?contractId='1'&" +"lastmodifieddate='"+DateTime.Now.ToString()+"'")); Console.WriteLine("is contract uptodate ? " + resp.First()); 
0
source

We can access RESTful browser browser services such as

http: // localhost: 8080 / Service / isContractUpToDate / {contractId} / {lastmodifiedDate}

But I think that we cannot specify the DateTime data type, as my understanding should be only a string.

+2
source

I found this series to be extremely useful and rich examples of how to implement WCF REST services (including query strings and filters as a call from client code).

+1
source

This works for me:

?startDate=2014-04-11T14:45:00&endDate=2014-05-31T23:59:59

I use this line to send URL parameters to a REST service hosted in an ASP.NET application.

0
source

Here is how you can call it according to MSDN

 http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')/Orders?$filter=ShippedDate gt datetime'1997-09-22T00:00:00' datetime'1997-09-22T00:00:00 
0
source

Source: https://habr.com/ru/post/1345307/


All Articles