Accepting application/x-www-urlencode format data
-
I'm just learning Asp.net Web APIs. It was smooth until it's simple application/json type headers to deal with. But now I'm trying to submit data with Content-Type:application/x-www-urlencode , but it's been really tough to get it working. I tried different things, right from using [FromBody] attrib to "AliasBinder" etc. But nothing seem to work. The API is dead simple , The code looks like: class Point { int x {get;set;} int y {get;set;} } [httpPost] public string getValues(Point pt_in) { Diagnostics.Trace.TraceInfo(pt_in.x); //Also tried using HttpUtility.Encode/Decode to read pt_in.x } that's it. When I try from postman, different combo, different errors: "Message": "The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource." And at times (during various trial), I get 415 unsupported media type* error I just need a simple Asp.net Web API example, where we are able to push Data as x-www-urlencode format & read the values inside the API. Any help please? thanks Sum
-
I'm just learning Asp.net Web APIs. It was smooth until it's simple application/json type headers to deal with. But now I'm trying to submit data with Content-Type:application/x-www-urlencode , but it's been really tough to get it working. I tried different things, right from using [FromBody] attrib to "AliasBinder" etc. But nothing seem to work. The API is dead simple , The code looks like: class Point { int x {get;set;} int y {get;set;} } [httpPost] public string getValues(Point pt_in) { Diagnostics.Trace.TraceInfo(pt_in.x); //Also tried using HttpUtility.Encode/Decode to read pt_in.x } that's it. When I try from postman, different combo, different errors: "Message": "The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource." And at times (during various trial), I get 415 unsupported media type* error I just need a simple Asp.net Web API example, where we are able to push Data as x-www-urlencode format & read the values inside the API. Any help please? thanks Sum
Sending HTML Form Data in ASP.NET Web API: Form-urlencoded Data | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Sending HTML Form Data in ASP.NET Web API: Form-urlencoded Data | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer