I have a problem getting a a request message I am getting the data that I need with a content type x-www-form-urlencoded but in a form of JSON(see image). I use Ngrok for simulating the passing of data to a server.
See image here for the form that I am getting
The Problem is I always get a NULL value.
I already build a class that should've getting the data(I edited this one, before I use for the Entry part):
public class FormData
{
public string @object { get; set; }
public Entry[] entry { get; set; }
public string resource_url { get; set; }
}
public class Entry
{
public string uuid { get; set; }
public string[] changed_fields { get; set; }
public string time { get; set; }
}
My [HttpPost] in my Controller that I already used are:
- using the formData class and returning it, adding ToString()
- using JObject even though it is a Form (Trying my luck to get that JSON format)
- using [FromBody],[FromQuery] (but I get a unsupported media type) I used FromForm but still getting a NULL value
- Tried desrializing it
- Tried using "object" to support all classes. Still Null.
- Using public HttpResponseMessage
- Tried using ApiController extension.
Still getting NULL Values on these.
Now I'm using this just to return a 200 response
public string Post(FormData deviceData)
{
string please = deviceData.ToString();
return please;
}
If you cant see the picture above, here is the request that I am getting:
POST /api/values HTTP/1.1
Host: localhost:50754
User-Agent: ServiceM8-Platform/1.0
Content-Length: 233
Accept: */*
Content-Type: application/x-www-form-urlencoded
X-Forwarded-For: 35.176.170.33
X-Original-Host: 1fbbf508.ngrok.io
{"object":"JOB","entry":[{"uuid":"d4798ca6-5022-4527-b4ac-b6c7e822490b","changed_fields":["status"],"time":"2018-09-28 09:43:32"}],"resource_url":"https:\/\/api.servicem8.com\/api_1.0\/JOB\/d4798ca6-5022-4527-b4ac-b6c7e822490b.json"}
Any help are welcome.