I’m pulling my hair out with this one…
I need to send a PUT request to my website to allow a license to be changed from Delivered to Active, The API documentation for the license key provider I’m using says you need to send a body text in the PUT request.
My code looks like this
IEnumerator PutUpdateLicense()
{
if (activationCheck == true)
{
string authorisation = authenticate("****", "****");
string info = "{'\','status':'ACTIVE','\'}";
using UnityWebRequest licenseRequest = UnityWebRequest.Put(URL + "licenses/" + inputLicense, info);
{
Debug.Log(UnityWebRequest.Put(URL + "licenses/" + inputLicense, info));
licenseRequest.SetRequestHeader("AUTHORIZATION", authorisation);
byte[] myData = System.Text.Encoding.UTF8.GetBytes(info);
UploadHandlerRaw uH = new UploadHandlerRaw(myData);
licenseRequest.uploadHandler = uH;
licenseRequest.SetRequestHeader("Content-Type", "application/json");
yield return licenseRequest.SendWebRequest();
if (licenseRequest.result == UnityWebRequest.Result.ConnectionError)
{
Debug.LogError(licenseRequest.error);
}
else
{
updatedCheck = true;
ValidateKeyButton();
}
}
}
}
If I send an activation call (Which is run before the above code), it activates the license fine as this arrives in Debug.Log
{“success”:true,“data”:{“id”:11,“orderId”:78,“productId”:58,“userId”:1,“licenseKey”:“PT-3415-3822”,“expiresAt”:“2024-03-21 13:01:50”,“validFor”:3,“source”:1,“status”:2,“timesActivated”:1,“timesActivatedMax”:1,“createdAt”:“2024-03-18 13:01:50”,“createdBy”:1,“updatedAt”:“2024-03-18 13:03:17”,“updatedBy”:1,“activationData”}
Then the PutUpdateLicense code runs and connects as it doesn’t give back an error loop, It should then change the status from “2” to “3” to show it’s active.
Then once the UpdateChecked is set to true, it then validates the license to make sure the changes have been made, although it comes back with a successful connection the status remains at “2” (marked in bold)
{“success”:true,“data”:{“id”:11,“orderId”:78,“productId”:58,“userId”:1,“licenseKey”:“PT-3415-3822”,“expiresAt”:“2024-03-21 13:01:50”,“validFor”:3,“source”:1,“status”:2,“timesActivated”:1,“timesActivatedMax”:1,“createdAt”:“2024-03-18 13:01:50”,“createdBy”:1,“updatedAt”:“2024-03-18 13:03:17”,“updatedBy”:1,“activationData”}
I’ve tried looking for other guides but most of them deal with POST or GET, I have a feeling that the json string might be wrong because if I use ReqBin and set it up for the PUT request, it goes through absolutely fine (See uploaded image)