- I am making a POST api call to my server using UnityWebRequest (Unity version that i have is 2017.4.0f1)
- I am sending some data elements in the request body to the server, which inserts into my DB and returns a response body, which is a json string
- I am using UnityWebRequest.downloadhandler.text to read the response message, but it is empty, eventhough the data elements are getting inserted into my DB. request.downloadHandler.data.Length also gives me 0
- Making the same call through Postman returns me the appropriate response (so does using HTTPWebRequest and reading the response via a stream reader)
This is the code snippet that i have for it:
UnityWebRequest request=new UnityWebRequest(endpoint,"POST");
request.SetRequestHeader("Content-Type","application/json");
request.SetRequestHeader("host",host);
request.SetRequestHeader("X-Amz-Date",dateTime);
request.SetRequestHeader("Authorization",authorizationHeader);
request.uploadHandler=(UploadHandler)new
UploadHandlerRaw(Encoding.UTF8.GetBytes(requestParameter));
request.chunkedTransfer=false;
request.downloadHandler=new DownloadHandlerBuffer();
request.SendWebRequest();
print(request.downloadHandler.text);
Please advise as to what i am doing wrong here.....