Not sure what I'm doing wrong here.
Trying to post a Base64 encoded byte array, and getting a 404.
The thing is, when I try it with a normal value ("test"), it works.
API:
[HttpPost]
public IHttpActionResult Post(dynamic data)
{
// ...
return Ok();
}
Client:
public static bool UploadDocument(string base64Image)
{
// ...
using (var handler = new HttpClientHandler() { UseDefaultCredentials = true})
using (var client = new HttpClient(handler))
{
var data = new { Image = base64Image }; // Image = 123 (or any random value) Works.
var res = client.PostAsJsonAsync(@"(url)", data).Result;
if(res.IsSuccessStatusCode)
// ...
}
}
Tried a couple other variations, also tried using WebRequest instead. The issue remains.
PostAsJsonAsncto serialise the image to base 64. Is that definitely happening? What happens if you manually encode the image object as base 64, then attempt to post it?