Put Request Like PostMan , How to do it ?
Hello , I am trying to use Put Method like Postman , But I can't Figure out the problem I was looking everywhere , and they always use in string parameter rawdata and what is rawdata content ? I don't know Here is my use in Postman and here is my try in unity So Help please , Thanks
PostMan 
Here is my try in Unity
IEnumerator PutRequest()
{
using (UnityWebRequest www = UnityWebRequest.Put("http://0000000/smallapi2/products?id=1", "{'name':Chipsy,'product_price':12,'productPurchasedCounter':142}"))
{
www.SetRequestHeader("Content-Type", "application/json");
www.SetRequestHeader("Accept", "text/json");
yield return www.SendWebRequest();
try
{
if (www.isNetworkError)
{
Debug.Log("PUT ERROR: " + www.error);
}
else
{
Debug.Log(www.uploadHandler);
Debug.Log("Uploaded!!");
}
}
catch (Exception)
{
Debug.Log("NO QORY");
}
}
}
Answer by xxmariofer · Aug 25, 2021 at 07:04 AM
whats the error returned? I doubt using single ' is valid in json format, you should be using " (you can scape the character like this: \") Also I have never seen doing a GET and a PUT in the same request, is that possible?
can you write it to me in correct format without problem in unity ? where is GET request here ?
"{\"name\":\"Chipsy\",\"product_price\":12,\"productPurchasedCounter\":142}"
this is an example, remember that all strings (chipsy also) needs to be between ""
the Get is probably not an issue and maybe Im simply mistaken, but the main differnet between Get and PUT/POST is that the parameters go in the url like in your example (?id=1) I have never seen that, but I am far from being a web developer expert, I dont understand why wouldnt you simply add the id=1 in the json with the rest of the parameters, but maybe is there a hidden reason I dont understand
Your answer
Follow this Question
Related Questions
How to integrate Google APIs functionality for Sign=in/Login purpose in unity2017? 0 Answers
,Call api and wait answer to return (async?) 1 Answer
Unity Tools - How could I make a login system or api like paid assets? 0 Answers
Unity 2019.4.3 steamvr asset pack - HMD/controllers not being used, defaults to stereo display 1 Answer
Is there a replacement for AssetDatabase.CanOpenAssetEditor 0 Answers