- Home /
Webrequest put bodyData?
Hi,
Can anyone say what the PUT method's bodyData should look like? I have to send a value for "token" but i can't get it right. I tried creating a class with a public string token variable and turning it into Json, then supplying the PUT with this Json. I also set the header right, it only needs "Authorization" and the response code is 200 so I'm sure that's right, but the value of token on the server is never set. Tried it with postman and it works fine... Any ideas?
Please note this is Webrequest, not WWW.
Answer by Bunny83 · Oct 23, 2018 at 09:04 AM
what the PUT method's bodyData should look like
No, nobody can say that. Both, POST and PUT can have a message body. That can contain any kind of data. It could be a binary file, it could be json, it could be url encoded fields, ... What you have to send depends entirely on your webservice and what it's expecting. Since we don't know what web service you try to communicate with and what
but the value of token on the server is never set
is actually referring to, we can't really answer this question. Is the server actually run by you? Did you write the serverside code or do you try to communicate with a third party web interface? You should add more details to your question. Are you sure that the API you try to communicate with expects json and not url encoded data?
I don't run the server, the server expects json, should be only one string variable called "token". Serverside code is written by someone else in our company. For now, we changed the method to POST and used WWWForm and it works that way, but I would like to know why I can't get the PUT working.
Your answer
![](https://koobas.hobune.stream/wayback/20220612180808im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
multiple webrequests, one exception causes next to time out, rest are fine 0 Answers
Error getting response stream (Write: The authentication or decryption has failed.): SendFailure 0 Answers
UnityWebRequest blank error message on Hololens 0 Answers
A method for streaming custom audio from the hard drive 0 Answers