Hi, I’m trying to use some of the data from this blog post/video on integrating Courier with Unity:
I’ve modified the request (since I only have one piece of data to send), but I keep getting an HTTP 400 error.
private IEnumerator SendNotification()
{
WWWForm form = new WWWForm();
form.AddField("event", EVENT_ID);
form.AddField("recipient","client");
form.AddField("data", "{\"RoomCode\":" + roomCode + "\"}");
form.AddField("profile", "{\"email\":\"" + setHost.hostInviteEmail + "\"}");
//setHost.hostInviteEmail is the email address input by the host to send to the client
using (UnityWebRequest www = UnityWebRequest.Post("https://api.courier.com/send", form))
{
www.SetRequestHeader("Authorization", "Bearer " + AUTH_KEY);
yield return www.SendWebRequest();
if (www.result != UnityWebRequest.Result.Success)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
}
}
}
The Auth Key and Event IDs are set elsewhere in the script.
I’m sure it’s some issue with parsing the webrequest.