Forum Discussion

jeffshurtliff's avatar
5 years ago

Possible to update custom metadata field with API v2 POST call?

Does anyone know if it is possible to update a custom metadata field using the v2 API or is it only possible to do so using the v1 API? In our environment we have a side nav component that is popula...
  • DougS's avatar
    5 years ago

    You should probably stick with the REST V1 call since we don't currently support setting a node setting in REST V2.

    For REST V1 calls can do a multipart/form-data request and include your parameters as form parameters:

    curl --location --request POST 'http://yourcommuntiy.com/restapi/vc/categories/id/intermingles/settings/name/custom.side_nav/set' \
    --header 'Content-Type: application/json' \
    --header 'Li-Api-Session-Key: JO_JDmgXJ5WI8P_2b2bnBXzSsX5-SHCPneB0qLxYttQ.' \
    --form 'value={ "json": "string" }'

    If you are doing the call in a Freemarker endpoint, you could make a call like the following (it's ok to use a query param b/c the code is executing server-side):

    <#assign settingPostCall = restBuilder()
       .version("v1")
       .method("POST")
       .path("/categories/id/" + categoryId + "/settings/name/custom.side_nav/set")
       .queryParam("value", jsonDataString) />
    <#assign resp = settingPostCall.call() />

     

    I hope that helps!

    -Doug