Quantcast
Viewing all articles
Browse latest Browse all 387

How to use UnityWebRequest to upload a File via Invision REST API

Hello There I've been using UnityWebRequest to succesfully access some REST API endpoints. However when it comes to uploading files I couldn't get it to work and am wondering (this might be a bit of an open-ended question) what I am overlooking. I create a WWWForm like this, filling it with required parameters for the API request: WWWForm form = new WWWForm(); form.AddField("category", 6); form.AddField("title", "testing.txt"); form.AddField("description", "Just a file"); form.AddBinaryData("files", data, "testing.txt", "text/plain"); data is the byte array of the file im trying to upload. I then do a `UnityWebRequest.Post(url, form)` and set the request headers. However I always end up getting a "NO_FILES" response from the server (No files were supplied). Here's the documentation of the API-Endpoint I'm trying to access (with a short description of the files parameter and error codes): https://invisioncommunity.com/developers/rest-api?endpoint=downloads/files/POSTindex Instead of WWWForm, I've also tried using a List like this and received the same "NO_FILES" error from the server. List formData = new List(); formData.Add(new MultipartFormDataSection("category", "6")); formData.Add(new MultipartFormDataSection("title", "testing.txt")); formData.Add(new MultipartFormDataSection("description", "Just a file")); formData.Add(new MultipartFormFileSection("files", data, "testing.txt", "text/plain")); Thanks!

Viewing all articles
Browse latest Browse all 387

Trending Articles



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