What Is The Best Way To Update an Items Custom Fields

meatcomputermeatcomputer Member Posts: 23

Hello,

I was wondering what was the best API call to make to update the custom fields associated with an item. Especially custom fields which have multiple choices to them. I was able to update custom fields that just have a single value associated with them but I can't figure out how to update custom fields which have dropdown choices associated with them.

Thanks.

5 comments

  • gregaricangregarican Member Posts: 663 

    I recall testing this out awhile back. Off the top of my head, I recommend issuing a GET request for a product item with the various custom fields assigned to it. Review the JSON response and you can model your PUT request.

  • meatcomputermeatcomputer Member Posts: 23

    Thanks, that was helpful.

  • madhupatelmadhupatel Member Posts: 12
    edited March 3

    Hi @Gregarican

    Can you please guide me on how can I create a product with custom fields?

    when I'm trying without custom fields it working fine but when I try with the custom fields I'm getting the below error.

    Error:

    {

      "httpCode": "400",

      "httpMessage": "Bad Request",

      "message": "The child object (ItemCustomFieldValue: 2) either does not exist or is archived and cannot be updated via the parent object (Item: ).",

      "errorClass": "Exception"

    }

  • gregaricangregarican Member Posts: 663 

    Have you properly defined the custom fields, so that the new product is hitting the correct elements? As I had advised the OP, it's usually best to issue a GET request including the custom fields relations in the response. Against a product that already has these custom fields defined.

    So that way you can mimic what you see in the JSON response body when trying to issue a POST request that will create a new product with these custom fields defined.

  • madhupatelmadhupatel Member Posts: 12

    Thank you for the help @Gregarican. now it's working for me.

Sign In or Register to comment.