Jump to content


Click here to lend your support to: Traq and make a donation at pledgie.com !
Photo

Can't set values of custom fields via the API?

api customfields

  • Please log in to reply
4 replies to this topic

#1 harinder

harinder

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 19 June 2016 - 10:26 PM

Hi!

 

Are we able to set/modify the values of custom fields via the API?

 

Using the API, I am able to insert new tickets. But it looks like the API won't set values of my custom fields.

Here is the image (http://imgur.com/fAnRxDs) which shows one of my custom fields. When I add a new ticket, the summary and description are set just fine, but my custom field doesn't get set.

 

This custom field is of type select, I also tried to set a free form field but was unable to.

 

POST http://<hostname>.com/traq/<project>/tickets/new HTTP/1.1

summary=My Summary&description=My description&ig_device=Android

 

Looking forward to you resposne.

 

 

EDIT:  Here is me doing the same with cygwin

 

$ curl http://<hostname>.com/traq/<project>/tickets/new -d access_token=0f9503b6729eaaa5c0ec23f7fc5d6861a9065768 -d summary="Testing" -d description="New Description" -d ig_device="Android" -d from="[email protected]"
{"status":1,"version":"1.0","ticket":{"extra":[],"tasks":"[]","summary":"Testing","body":"New Description","ticket_id":"15","is_closed":1,"created_at":"NOW()","id":"15","votes":0,"project":{"id":"1","name":"iGurbani"},"user":{"id":"1","username":"admin","name":"Administrator"},"assigned_to":null,"milestone":null,"version":null,"component":null,"status":null,"priority":null,"severity":null,"type":{"id":"1","name":"Defect"}}}
 

 

EDIT2: Fix link to the image

 

Thank you!

Harinder



#2 Jack

Jack

    Project Founder

  • Administrators
  • 673 posts
  • LocationAustralia

Posted 21 June 2016 - 12:22 PM

Setting the value of a custom field is different than other fields, it's also a little weird.

 

The current way is instead of using the custom fields "slug", you need to pass "custom_field[x]", where "x" is, is the custom fields ID.

 

For example, if we had a custom field named "PHP version" and its ID is 3, we'd set the value of it like so:

POST http://my.site/traq/project/tickets/new
custom_fields[3]=7.0

Edited by Jack, 21 June 2016 - 07:22 PM.
Fix typo


#3 harinder

harinder

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 21 June 2016 - 06:54 PM

Thank you for your response Jack. That way actually didn't work me. So I manually updated a ticket while Firebug was up hoping that you use the API as well. That's when I saw that there was a slight typo in your response. It's custom_fields, you were missing the trailing 's'.

 

Now I'm using custom_fields[id] and it is working well. Thanks for your help!



#4 Jack

Jack

    Project Founder

  • Administrators
  • 673 posts
  • LocationAustralia

Posted 21 June 2016 - 07:26 PM

That's when I saw that there was a slight typo in your response. It's custom_fields, you were missing the trailing 's'.

 

Ah, my bad, thanks for pointing out the typo.

 

In Traq 4.0, setting custom field values will be easier, they'll use the 'slug' field instead. This may also be done for Traq 3.7, but at the moment I'm focusing on 4.0.



#5 harinder

harinder

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 21 June 2016 - 08:56 PM

I'm tied to a hosting environment which only gives v3.6. Likely won't be able to upgrade anytime soon :-(





Also tagged with one or more of these keywords: api, customfields

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users