Hello,
I am working with a web API that requires a zero byte post. In my research I’m seeing there is not a way to do that but wanted to ping the team here to see if anyone’s had a creative solution. I was looking at this post: Error when creating request. POST request with a zero-sized post buffer is not supported - Questions & Answers - Unity Discussions and saw that I’m not the only person running into this issue. Unfortunately, the web API I’m trying to use doesn’t like the proposed solution in that post.
Here’s my code (pretty basic):
WWWForm form = new WWWForm();
Dictionary<string,string> headers = form.headers;
headers["Authorization"] = "Bearer " + Secret;
WWW www = new WWW(APIUrls.Urls["TokenGenerate"], form.data, headers);
yield return www;
I have tried sending in fake fields, zero byte arrays, empty lines, spaces, etc… but nothing is working except an empty body. Specifically, I get a BAD REQUEST error for anything other than an empty body. I have validated this via Fiddler as well. Any advice would be greatly appreciated!
My next thought is to create a proxy service that will accept a body and then relay to the API I want to use but before I do all that, I wanted to check in here.
Thank you!