- Home /
How do I post a cURL request from Unity?
I am considering implementing a system like Gumroad for license administration in my end software but to communicate with it's API I need to send cURL commands such as:
curl https://api.gumroad.com/v2/licenses/verify
I notice a number of other similar organisations to Gumroad also all seem to use cCURL to access their apis (SendOwl for example)
It seems quite important so how on earth do I do this from Unity? Thanks
I guess using wwwform, which u already included in your tag..
Im also finding the solution to sell a PC build directly, how's your experience with Gumroad?
Answer by kaplica · Mar 04, 2019 at 02:48 PM
It doesn't have to be cURL. What you need to do is to send a POST request to this API endpoint with the right data.
IEnumerator Upload()
{
WWWForm form = new WWWForm();
form.AddField("myField", "myData");
using (UnityWebRequest www = UnityWebRequest.Post("https://api.gumroad.com/v2/licenses/verify", form))
{
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
}
}
}
You can download a tool called Postman to simulate requests.
Your answer
Follow this Question
Related Questions
GET Request Wrapper 1 Answer
HTTP Response Headers? 3 Answers
Blank web server response in multiple type data submission 1 Answer
How do I send data over the internet? 0 Answers