API POST call works in POSTMAN but not in Unity

Hey everyone. In my project, after a player inputs their first name, last name, and email address, an API POST call is made sending these strings after being saved in variables. I have tested this call in POSTMAN and it works fine, but in Unity it gives me a “Generic / Unknown HTTP Error.”

IEnumerator AWSCall(){

 		WWWForm test_form = new WWWForm();
 		test_form.AddField("first_name", fName);
 		test_form.AddField("last_name", lName);
 		test_form.AddField("email_address", eMail);

 		using (var w = UnityWebRequest.Post(AWS_URL, test_form)){

 			yield return w.Send();
 			if(w.isNetworkError || w.isHttpError){

 				print(w.error);
 			}else{

 				print("Transfer Complete");
 			}
 		}

Anyone know what could be the issue? Thanks!

It looks like it’s a bag
https://forum.unity.com/threads/post-requests-doesnt-work-in-2017-3.510281/

I changed my methods from WWW to UnityWebRequest like this:

 IEnumerator Post()
 {
            string postData = "{....post data json...}";
            byte[] bytes = GetBytes(postData);
            using (UnityWebRequest www = UnityWebRequest.Put("http://localhost/api/PutMethod", rawData))
    		{
    			www.SetRequestHeader("Content-Type", "application/json");
    			www.SetRequestHeader ("Accept", "text/json");
    
    			yield return www.Send();
    
    			if (www.isNetworkError)
    			{
    				Debug.Log(www.error);
    			}
    			else
    			{
    				Debug.Log(www.downloadHandler.text);
    			}
    		}
    }

Hey guys, I am trying to invoke a Web Service in Unity, it requires first an access token that i’ll get it from this API : https://api.cognitive.microsoft.com/sts/v1.0/issueToken.
I order to recieve the access token, I should use a POST request with a Ocp-Apim-Subscription-Key as a header and no data will be passed in the HTTP body, it works correctly with Postman, but in Unity, i get this Error :

Error is : Generic/unknown HTTP error
UnityEngine.Debug:Log(Object)
<RequestToken>c__Iterator0:MoveNext() (at Assets/Scripts/Test.cs:26)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

This is my code :

using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

public class Test : MonoBehaviour
{
    public static readonly string accessUri = "https://api.cognitive.microsoft.com/sts/v1.0/issueToken";
    private string apiKey;
    private string accessToken;

    public void Doo ()
    {
        StartCoroutine(RequestToken());
    }

    public IEnumerator RequestToken()
    {
        UnityWebRequest request = new UnityWebRequest(accessUri, UnityWebRequest.kHttpVerbPOST);
        request.SetRequestHeader("Ocp-Apim-Subscription-Key", "a66ec1e2efed47639f22e2dc2e760d13x");

        yield return request.SendWebRequest();

        if (request.isNetworkError || request.isHttpError)
        {
            Debug.Log("Error is : " + request.error);
        }
        else
        {
            Debug.Log("downloadHandler Text : " + request.downloadHandler.text);
            Debug.Log("responseCode : " + request.responseCode);
            Debug.Log("isDone : " + request.isDone);
            Debug.Log("method : " + request.method);
        }
    }
}

Hey @montacerdk did you find a solution to this? cheers!