- Home /
Using an API KEY to post data
I have an api where you can run and save data. I pass here the api credentials, so i never done something like this beofre and i dont know how to do it
You would have to send the following value in the header
X-API-Key: LX741HHxU30PBo
and in the body a json like the following example
{ "time": "2020-07-02 21:59:16", "userId": "9.4424527-5", "actionTime": "2020-07-02 21:59:14", "actionGroup": "main", "actionId": "login", }
i use this code for the moment but is not working:
string jsonStringTrial = JsonUtility.ToJson(mydata);
UnityWebRequest www = UnityWebRequest.Get("http://eastus.cloudapp.azure.com:3003/api");
www.SetRequestHeader("LXFKz41HxU30PBo", jsonStringTrial);
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.LogError(www.error);
}
else
{
Debug.Log("Success");
}
}
Comment
Your answer
