Click here to Skip to main content
14,360,161 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to send a list of location objects to a web api in json format. But the parameter is always null.

public class location
       {
       public string Lat { get; set; }
       public string Long { get; set; }
       public DateTime timestamp { get; set; }
       }

public InsertUpdateResponse submitlocation(string Login_Token, string RouteJourneyId, DateTime timestamp, List<location> jsondata)


jsondata is always null.
my data is
[{\"Lat\":23.0106264,\"Long\":72.5055554,\"timestamp\":\"2019-10-09 13:02:43\"},{\"Lat\":23.0106264,\"Long\":72.5055554,\"timestamp\":\"2019-10-09 13:02:48\"}]"


What I have tried:

Tried sending the data from body but still getting a null.
public InsertUpdateResponse submitlocation(string Login_Token, string RouteJourneyId, DateTime timestamp, [FromBody]List<location> jsondata)
Posted
Comments
RickZeeland 7-Nov-19 5:26am
   
Could it be that you are using a free version of the API and exceeded the monthly limit of requests ?
F-ES Sitecore 7-Nov-19 5:45am
   
The data you send the api might need to be more like

jsondata:[{\"Lat\":23.0106264,\"Long\":72.5055554,\"timestamp\":\"2019-10-09 13:02:43\"},{\"Lat\":23.0106264,\"Long\":72.5055554,\"timestamp\":\"2019-10-09 13:02:48\"}]"
Richard MacCutchan 7-Nov-19 6:46am
   
You need to show the actual code that creates the json object and passes it to the submitlocation method.

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100