Support

Expand all | Collapse all

REST API set field to pick list value

Jump to Best Answer
  • 1.  REST API set field to pick list value

    Posted 12-10-2019 14:08
    I'm using REST in C# to update several items at once. I want to set the value of some fields to a value from a pick list. How could I do this in C#?

    ------------------------------
    Jack
    ------------------------------


  • 2.  RE: REST API set field to pick list value
    Best Answer

    Posted 12-11-2019 13:52
    I've figured it out. Once you have the JObject item you want to edit and the int ID of the picklist option you want to set a field to, you can do something similar to below:
    public void updateItemPickList(long itemId, string field, int value)
    {
        setLockState(true, itemId);
        JObject item = getItem(itemId);
        item["fields"][field] = value;
        try
        {
            putItem(itemId, item);
            setLockState(false, itemId);
        }
        catch (WebException)
        {
        }
    }


    ------------------------------
    Jack
    ------------------------------