Hi, I’m trying to generate a new product key with the API for a product which has one custom field. I’m unsure how to format the custom fields and I fail at doing it correctly apparently. Every attempt results in a message “Missing custom field ids and values!”.
I’m using postman to test my API calls, this is a curl version of it
curl -X POST -H “Content-Type: application/json” -d ‘{
“api_key”: “My-API-KEY”,
“version_id” : “12345”,
“cust_field_id[]” : “300”,
“cust_field_value[]” : “2017-10-10”
}’ “https://cryptlex.com/services/api/pkey/generate”
I’ve also tried and failed with this
curl -X POST -H “Content-Type: application/json” -d ‘{
“api_key”: “My-API-KEY”,
“version_id” : “12345”,
“cust_field_id[]” :[ “300”],
“cust_field_value[]” : [“2017-10-10”]
}’ “https://cryptlex.com/services/api/pkey/generate”
Hi,
We recommend using the PHP, C# or VB.NET wrapper classes available on the API page in the dashboard. In case you want to test it using postman then instead of json, body should be of type form-data (application/x-www-form-urlencoded)
Thanks, that did the trick. By the way, the other API methods I’ve tested in postman until now (get, id and find) also work with raw json (application/json).
I’ve now created a new product key with a custom field. I can confirm the custom field is correctly filled in, because the value shows up correctly when I use pkey/get to see the key. However, when I look at the key in the product keys webinterface I don’t see the value of the custom field. That value is empty.
In order to see the custom field, you click the product key and in the activations dialog you can see a custom fields button at the top. When you click that it will show the associated custom field.
Yes, I’ve done that. But even though I’ve generated the product key with a value in that field, and I can see that value when I check the product key with the API, the field value is empty when I look at it in that dialog.
This is the product key when I get it with the API. You can see the “subscription_started” custom field has a value attached to it.
This is the same product key in the web interface
And when I press the “Custom Fields” button, I can see the list with custom fields where each of the field values is empty.
It seems you created license key first and custom fields later, it should not happen in case license key is created after the custom fields. Seems like a bug in dashboard if custom field is created after the license key. Can you please confirm that?
That’s definitely possible as I’m trying stuff out. However when I generate a new key through the API (I did just now) I get the same scenario.
I’ve also imported about 275 keys with data in the custom fields and these values turn up just fine in the dashboard.
By the way, I appreciate your prompt responses! Thanks a lot for that.
Can you try generating the key using the wrapper classes, as they take care of setting custom fields properly. May be something is going wrong when using postman.
That gives me the same results: no custom field value in the dashboard while it’s visible through the API. I also created a product key with an email to see if that turns up in the dashboard, and it does. I also made a key with a value in one of the custom fields which aren’t required, and these don’t show up in the dashboard. So it only seems to be constrained to the custom fields.
Does the issue replicate when you add keys through dashboard? When you click any key in dashboard, an ajax call is made, can you post the response for any key where custom field values are not showing up.
Indeed, creating a key in the dashboard also replicates the issue. And I can see the custom field in the response. It’s custom field 300 with the value “bingo”
{
“total”: 0,
“rows”: [],
“customFields”: {
“c_f”: [{
“@attributes”: {
“id”: “300”
},
“value”: “bingo”
}, {
“@attributes”: {
“id”: “301”
},
“0”: {}
}, {
“@attributes”: {
“id”: “302”
},
“0”: {}
}, {
“@attributes”: {
“id”: “303”
},
“0”: {}
}]
}
}
Maybe something messed up, some case came up which was not handled when you were trying stuff. Can you create a new version of the product, and try with that. We would try to replicate the issue, haven’t been able to so far.
Yes, I thought as much. I’ll wipe my product entirely and start from scratch and document what I’m doing.
I’ve got bad news and I’ve got good news. After wiping my products and keys and creating a new version I had exactly the same issue: values don’t turn up in the custom fields in the dashboard. But when I did it a second time it did work. I’ve documented both scenarios in the linked pdf here: https://dl.dropboxusercontent.com/u/378324/Cryptlex_2016-10-11_090540.pdf
Both scenarios are the same, except for the order I create the first two keys in. In the first scenario I create my first key with the API and the second one with the dashboard. In the second scenario I create my first key with the dashboard, and the second one with the API.
Hopefully you can get some useful information from my screenshots. And I appreciate the help you’ve been giving.
Thanks a lot for providing the replication steps. Would get the bug fixed as soon as possible.
After closer inspection it seems the number or type of custom fields also matter. I added another custom field to the second scenario and created a product key with the web API and my field values were gone again. Maybe it’s also because one custom field is required and another isn’t.
It was a minor json parsing bug in the dashboard which prevented the values from getting displayed. The bug is fixed now.