Problem with required fields in category using REST Api

Options

Hi,

I'm using REST Api to upload a document in Content Server and add to this document a category with required attributes.

I'm using the following call:POST /nodes/{id}/categories and i'm getting the following error:
org.springframework.web.client.HttpClientErrorException: 400 Bad Request

This error is obtained because the category contains a required attribute which is empty. With other categories without a required attribute the document is uploaded without problems.

How can i set the value for this required attribute in the call? Is there any other Rest call to upload a document with categories with the attributes filled?

Best regards.

Tagged:

Comments

  • Ferdinand Prantl
    Ferdinand Prantl E Community Moderator
    Options

    It should be possible with the latest patch,`by including the attribute values in the request body. But it does not work on my machine. Uploading a new document with catts & atts works:

    POST /api/v1/nodes
    Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryMRYGBMFzBICDtNEA
    
    ------WebKitFormBoundaryMRYGBMFzBICDtNEA
    Content-Disposition: form-data; name="body"
    
    {"name":"test","parent_id":7611,"type":144,"roles":{"categories":{"52271":{"52271_2":"test"}}}}
    ------WebKitFormBoundaryMRYGBMFzBICDtNEA
    Content-Disposition: form-data; name="file"; filename="test.txt"
    Content-Type: text/plain
    
    ...
    ------WebKitFormBoundaryMRYGBMFzBICDtNEA--
    

    Attribute keys are in the format {category_id}_[{set_id}_{set_row}]_{attribute_id}.

  • Hi Ferdinand Prantl,

    I tried that and it works correctly.

    Thanks.

    Best regards.

  • Hi Ferdinand Prantl,

    This last message worked in two different calls. A call to create the node and another to assign metadata. Now I need to do it in one call because the doc inherits metadata from the parent folder. I have tried what you indicated in your previous message and didn't work for me. You said taht in your machine was not working. Is there any evidence about this works?

    Thanks,

    Best regards.

  • Ferdinand Prantl
    Ferdinand Prantl E Community Moderator
    Options

    I am not sure how the inheritance with the CS REST API works. I think that you should inspect what catts & atts are to be inherited by one call and add the needed catts & atts data to the document creation call.

  • Someone knows, how to do it in Postman?

    without the Roles/CAT object it works fine, but how to handle the Roles with Postman (as form-data)? who to do it as "raw"?


  • jpluimers
    jpluimers E Community Moderator
    Options

    Moved topic to Content Server API, Rest and web-services forum as that better fits the question.

  • in my JS sample I dont have quotes around categories.