AddItem To Collection & Report Community Violation body not parsable

When trying to use the API endpoints AddItem To Collection and Report Community Violation i get this error message:

{“error”:“Bad Request”,“status”:400,“message”:“Request body was not parsable. Attempted Content-Type: “application/json””}

Im trying to access the API with Unity like this:

AddItem To Collection

UnityWebRequest www = UnityWebRequest.Post(krakenEndPoint + “/collections/” + collectionID + “/items”, data);

the data string contains: {“id”:168668043,“type”:“video”}

Report Community Violation

UnityWebRequest www = UnityWebRequest.Post(krakenEndPoint + “/communities/” + communityID + “/report_channel”, data);

the data string contains: {“channel_id”:35853648}

only thing i can imagine is a wrong data string, but in the docs its used like this

A quick look at UnityWebRequest's documentation and a few forum threads would suggest you can’t use the simple Post(url, datastring) with json data, it’s for url encoded form data. Check https://forum.unity3d.com/threads/unitywebrequest-post-url-jsondata-sending-broken-json.414708/#post-2719976

Thank you 3ventic i just found out ^^ you can use this at least for AddItem To Collection:

WWWForm data = new WWWForm();
data.AddField(“id”, videoID);
data.AddField(“type”, “video”);

i will try it out for the other api call as well

I can confirm this wörks.

You have to use application/x-www-form-urlencoded tho

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.