Custom fields in API

Avatar
  • updated
  • Completed
We have added a custom field for topics. We would like to be able to see the value of the custom field in the API. For example, I would expect this URL to return the topic, including all custom fields and their values:

https://userecho.com/api/feedback/414583.json?access_token=xyzxyzxyzxyz

How would you rate the customer service you received?

Satisfaction mark by Mathew Weaver 10 years ago

I am quite pleased with your quick response and that you have added this functionality as requested.

Add a comment about quality of support you received (optional):

Pinned replies
Avatar
Vladimir Mullagaliyev co-founder
  • Answer
  • Completed
Hi Mathew,
We will check custom fields in API and add if it doesn't exists.
Avatar
Vladimir Mullagaliyev co-founder
Quote from Vladimir Mullagaliyev
Will do it in 24 hours.
Completed.
Avatar
Mathew Weaver
Quote from Vladimir Mullagaliyev
Sorry, I mean a topic (not a comment).
You should POST "code_name" with "value" as a form variable. Like you do with a header, description, etc.
Suppose I want to update the custom field value for an existing topic without changing anything else about the topic (including any of the other custom field values). Would I post the following?
{
  "id": 419007,
  "custom_fields": [ { "code_name": "cf_122", "value": "99176" } ]
}

Would posting just that information update just that one custom field value for the existing topic?
Avatar
Mathew Weaver
Quote from Vladimir Mullagaliyev
Sorry, I mean a topic (not a comment).
You should POST "code_name" with "value" as a form variable. Like you do with a header, description, etc.
I tried to post to this URL:

https://earthsoft.userecho.com/api/forums/29467/fe...

and I get a 404 response error. The same URL returns correctly on GET, but POST fails. I am trying a follows:

Method = "POST"
ContentType = "application/json; charset=utf-8"
Content = {"id":419007,"custom_fields":[{"code_name":"cf_122","id":122,"value":"99185","name":null}]}

Can you help me figure out how why the POST is not working? I need to be able to update the custom field of an existing topic (not create a new topic).
Avatar
Vladimir Mullagaliyev co-founder
Quote from Mathew Weaver
I tried to post to this URL:

https://earthsoft.userecho.com/api/forums/29467/fe...

and I get a 404 response error. The same URL returns correctly on GET, but POST fails. I am trying a follows:

Method = "POST"
ContentType = "application/json; charset=utf-8"
Content = {"id":419007,"custom_fields":[{"code_name":"cf_122","id":122,"value":"99185","name":null}]}

Can you help me figure out how why the POST is not working? I need to be able to update the custom field of an existing topic (not create a new topic).
Hi Mathew.
This method works for new topics only.
We will release API v2.0 in 3 days and add update for topic to it.
Avatar
Vladimir Mullagaliyev co-founder
Quote from Mathew Weaver
I tried to post to this URL:

https://earthsoft.userecho.com/api/forums/29467/fe...

and I get a 404 response error. The same URL returns correctly on GET, but POST fails. I am trying a follows:

Method = "POST"
ContentType = "application/json; charset=utf-8"
Content = {"id":419007,"custom_fields":[{"code_name":"cf_122","id":122,"value":"99185","name":null}]}

Can you help me figure out how why the POST is not working? I need to be able to update the custom field of an existing topic (not create a new topic).
Hello Mathew,
We have released new API v2.0

It has method PUT for update topic.
Information about methods here http://www.userecho.com/dev/api/reference/
Also we have API explorer. You can test your requests here https://userecho.com/dev/api/explorer/

We have changed some input/output parameters in API 2.0. If you already use our API, please check new reqiests with your old parameters in API explorer and apply changes.

Thank you.

P.S.: Feel free to send bug reports.

Avatar
Mathew Weaver
Quote from Vladimir Mullagaliyev
Hello Mathew,
We have released new API v2.0

It has method PUT for update topic.
Information about methods here http://www.userecho.com/dev/api/reference/
Also we have API explorer. You can test your requests here https://userecho.com/dev/api/explorer/

We have changed some input/output parameters in API 2.0. If you already use our API, please check new reqiests with your old parameters in API explorer and apply changes.

Thank you.

P.S.: Feel free to send bug reports.

I tried the new PUT method to update a topic with a custom field value. I set the method to "PUT" and put the following in the request body:

{"id":419007,"cf_122":"99234"}

The response was { "status": "success", "data": <the full topic info> .... }. but the custom field value was not actually changed. I tried the same thing through the API Explorer with the same results (it said success but did not actually change the value).
Avatar
Vladimir Mullagaliyev co-founder
Quote from Mathew Weaver
I tried the new PUT method to update a topic with a custom field value. I set the method to "PUT" and put the following in the request body:

{"id":419007,"cf_122":"99234"}

The response was { "status": "success", "data": <the full topic info> .... }. but the custom field value was not actually changed. I tried the same thing through the API Explorer with the same results (it said success but did not actually change the value).
Hi,
You should PUT like this:
{"id":419007,"custom_fields":{"cf_122":"99234"}}
Avatar
Mathew Weaver
Quote from Vladimir Mullagaliyev
Hi,
You should PUT like this:
{"id":419007,"custom_fields":{"cf_122":"99234"}}
Great, thank you. I got it working.

It would be good if the documentation (http://www.userecho.com/dev/api/topics/update) was a little more clear with regards to updating custom fields. Perhaps you could include another request example that updates a custom field.
Avatar
Vladimir Mullagaliyev co-founder
Quote from Mathew Weaver
Great, thank you. I got it working.

It would be good if the documentation (http://www.userecho.com/dev/api/topics/update) was a little more clear with regards to updating custom fields. Perhaps you could include another request example that updates a custom field.
Thank you!
We have fixed our API documentation.
Avatar
Mathew Weaver
Quote from Vladimir Mullagaliyev
Hi Mathew,
We will check custom fields in API and add if it doesn't exists.
This appears to have stopped working. Our code makes the HTTP PUT request to set a custom field. The response is success, but the custom field value never shows up in the topic. Here is an example:

http://forum.earthsoft.com/topic/444028-is-ue-webh...

Here is the API URL that is being used:

https://earthsoft.userecho.com/api/v2/forums/29467/topics.json?access_token=xxxx"

Here is the data being PUT:

{"id":444028,"custom_fields":{"cf_122":"100932"}}

This was working fine previously, but it does not seem to be working today.