Quantcast
Channel: Questions in topic: "webrequest"
Viewing all articles
Browse latest Browse all 387

,Convert Curl command with wav file to Unity web request

$
0
0
,Currently trying to convert a curl command to Unity Web request Curl Command: curl -H “x-app-key:APP_KEY_HERE“ / -F " file=@AudioFile.wav" / -F "user_token=USER_TOKEN_HERE" / -F "category=orange" / https://api.soapboxlabs.com/v1/speech/verification And the code I've attempted: private string url = "https://api.soapboxlabs.com/v1/speech/verification"; private string apiKey = "123456789"; void Start() { StartCoroutine(MakeSoapboxRequest()); } IEnumerator MakeSoapboxRequest() { List form = new List { new MultipartFormFileSection("file", "Assets\\Pilot1\\Audio\\soapbox_test.wav"), new MultipartFormDataSection("user_token", "aaa1234567"), new MultipartFormDataSection("category", "orange") }; /* WWWForm form = new WWWForm(); form.AddField("file", "@Assets\\Pilot1\\Audio\\soapbox_test.wav"); form.AddField("user_token", "abc123"); form.AddField("category", "orange");*/ UnityWebRequest request = UnityWebRequest.Post(url, form); request.SetRequestHeader("x-app-key", apiKey); yield return request.SendWebRequest(); if(request.isNetworkError || request.isHttpError) { Debug.LogError(request.error); } else { Debug.Log("No soapbox error"); Debug.Log(request.downloadHandler.text); } } Keep getting an error HTTP/1.1.400 Bad request As you can see I've tried and commented out, WWW form as well. Is it something to do with me sending the wav file? I've tried looking into sending it as bytes but was left confused. The API I'm sending it to only takes wav files. It returns a JSON file. I'm just using the downloadHandler.text as a test. Any help would be appreciated. I haven't used CURL before and it's my first time trying Unity Web Requests.

Viewing all articles
Browse latest Browse all 387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>