Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: (untagged)
This is my first time down the API REST road. This is a function in my desktop client application. It appears that the format of the dates is the cause of the errors. Could anyone please see if there is a malformality in the string. Part A is the first attempt at it, part B is where I am at now.
Thanks.

VB
Public Shared Function SearchCurrentIncidents(ByVal incidentTypeID As Int32, ByVal beginDate As DateTime, ByVal endDate As DateTime) As List(Of IncidentNotificationData)
 
Try

'A) Response is a 404 Not Found - I suspect too many '/' in the date arguments

Dim uri As String = String.Format(My.MySettings.Default.Local &
 "/IncidentNotificationRESTService.svc/SearchCurrentIncidents/{0}/{1}/{2}",       incidentTypeID, beginDate, endDate)


uri is:
http://localhost:60420/IncidentNotificationRESTService.svc
/SearchCurrentIncidents/1/1/14/2013 11:11:55 AM/1/14/2016 11:11:55 AM

VB
'B) Response is a 400 Bad Request 

Dim uri As String = String.Format(My.MySettings.Default.Local &
 "/IncidentNotificationRESTService.svc/SearchCurrentIncidents/{0}/{1}/{2}",    	 
  incidentTypeID,
  HttpUtility.UrlEncode(beginDate.ToString("yyyy-MM-ddTHH:mm:ssZ")),
  HttpUtility.UrlEncode(endDate.ToString("yyyy-MM-ddTHH:mm:ssZ")))


uri is:
http://localhost:60420/IncidentNotificationRESTService.svc/SearchCurrentIncidents/1/2014-0114T13%3a53%3a44Z/2016-01-14T13%3a53%3a44Z

VB
Dim request As WebRequest = WebRequest.Create(uri)
throws exception on this call:
   response = request.GetResponse()...
Posted
Updated 14-Jan-16 14:10pm
v2
Comments
Sergey Alexandrovich Kryukov 14-Jan-16 19:32pm    
Not clear. Time is one thing, and URI is something different. What do you want to achieve?
—SA
MainFrameMan_ALIVE_AND_WELL$$ 1-Feb-16 19:13pm    
Since I can't answer my own question, I will have to explain what the problem was. It was in the format of the method in the contract on the IIS server. Instead of the above SearchCurrentIncidents/{0}/{1}/{2} it was using commas: SearchCurrentIncidents/{0},{1},{2}"... all is well again, until next time. Thanx 4 the help Garth, I did learn a little more on protocals with the URL you sent me.

1 solution

does any of this HTTP/1.1: Protocol Parameters[^] help you ?

(see 3.3.1 for example)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900