Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<form method="post" action="http://test.co.in/api/bus/search_trip.php">
<textarea name="request">
 { "uid" : "XXXX", "pin":"XXXXX", "source_id":"1270", "destination_id":"323", "date":"25-04-2017"  }
</textarea>
 
<!--<input type="text" name="value" value="json">-->
<input type="submit" name="submit" value="submit">
</form>


What I have tried:

when i m giving the request to the given url using ASP.NET C# it returns only "Invalid Request Format"
Posted
Updated 18-May-17 14:17pm
Comments
Richard MacCutchan 5-May-17 3:07am    
You need to check the PHP code to see what format it is expecting.

1 solution

C#
string json = "{\"uid\": \"xxxx\",\"pin\": \"xxxx\",\"source_id\": \"1270\",\"destination_id\": \"323\",\"date\": \"05-05-2017\"}";
var httpContent = new StringContent(json, Encoding.UTF8, "application/json");
using (var httpClient = new HttpClient())
{
    // Error here
    var httpResponse = await httpClient.PostAsync("http://pudhukadai.co.in/api/bus/search_trip.php", httpContent);
    if (httpResponse.Content != null)
    {
        // Error Here
        var responseContent = await httpResponse.Content.ReadAsStringAsync();
    }
}

and you may want to look at Newtonsoft.Json to handle creating the Json string.
 
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