Support

Expand all | Collapse all

Unable to update jama item using PUT rest api and curl

  • 1.  Unable to update jama item using PUT rest api and curl

    Posted 07-17-2019 13:37
    ​Hi

    I am trying to update description filed for my item in jama using curl and PUT rest api. Below is the curl command I am using . I am using windows to use the CURL . The field has read write permission.I have admin access

    curl -H "Content-Type: application/json" -u pottic:July2019# -X PUT --data "{\"project\":45,\"fields\": {\"name\":\"New requirement X\",\"description\":\"Test requirement for good\",\"systemprocess$128\":[514],\"systems_impacted$128\":[627],\"business_owner$128\":49},\"parent\":{\"item\":10275}}" "https://brg-jama-tst.state.mi.us/rest/latest/items/10276"


    Error I am encountering

    {"meta":{"status":"Bad Request","timestamp":"2019-07-17T17:25:34.677+0000","message":"You must set the following required fields. fields: systemprocess$128, systems_impacted$128, business_owner$128"}}


    Kindly let me know how to pass the correct response so that I can update the description field using PUT and curl.

    Thanks


    ------------------------------
    Chai P
    aaa
    ------------------------------


  • 2.  RE: Unable to update jama item using PUT rest api and curl

    Posted 07-17-2019 14:36
    Chai:

    Welcome to the Community!

    You are going to want to use PATCH instead of PUT.  PUT expects ALL fields to be updated and it looks like you are only updating one field.

    Best,

    ------------------------------
    Chloe Elliott
    Jama Software
    Portland OR
    ------------------------------



  • 3.  RE: Unable to update jama item using PUT rest api and curl

    Posted 07-17-2019 18:03
    Hi

    I tried to use PATCH as suggested below is my  curl command ​

    curl -H "Content-Type: application/json" -u pottic:July2019# -X PATCH --data "{\"fields\": {\"description\":\"Test requirement for good\"}}" "https://brg-jama-tst.state.mi.us/rest/latest/items/10276"

    I am still getting error

    {"meta":{"status":"Bad Request","timestamp":"2019-07-17T22:00:45.509+0000","message":"op must be provided in all RequestPatchOperations"}}

    Kindly help how to update using CURL and rest api the jama item field (description)


    ------------------------------
    Chai P
    aaa
    ------------------------------



  • 4.  RE: Unable to update jama item using PUT rest api and curl

    Posted 07-18-2019 06:45
    Hi

    I am waiting for reply on updating using curl as PATCH  as I am still getting error as posted above

    ------------------------------
    Chai P
    aaa
    ------------------------------



  • 5.  RE: Unable to update jama item using PUT rest api and curl

    Posted 07-18-2019 12:58
    Edited by Chloe Elliott 07-18-2019 13:22
    Chai:

    The error message indicates that you need to choose a CRUD (create, retrieve, update, delete) "op" included in your curl. Example:

    "[ { \"op\": \"update\", \"path\": \"/fields\", \"value\": {\"description\":\"Test requirement for good\"} }]"

    One way you could generate the right curls for your endpoints would be to generate them in Swagger. You could either use Swagger directly to run your curls or you can utilize it to generate the correct ones, per your needs and parameters, and then use the curl however you want.

    Best,

    ------------------------------
    Chloe Elliott
    Jama Software
    Portland OR
    ------------------------------



  • 6.  RE: Unable to update jama item using PUT rest api and curl

    Posted 07-18-2019 16:21
    Hi

    I tried with below curl command

    curl --header "Content-Type: application/json" --header "Accept: application/json" -u pottic:July2019# -X PATCH --data "[ { \"op\": \"update\", \"path\": \"/fields\", \"value\": {\"description\":\"Test requirement for good XXX\"} }]" "https://brg-jama-tst.state.mi.us/rest/latest/items/10276"

    Getting the below error

    {"meta":{"status":"Bad Request","timestamp":"2019-07-18T20:19:37.323+0000","message":"No enum constant com.jamasoftware.contour.rest.versions.v1.domain.PatchOperation.UPDATE"}}

    Kindly let me know how to resolve it




    ------------------------------
    Chai P
    aaa
    ------------------------------



  • 7.  RE: Unable to update jama item using PUT rest api and curl

    Posted 07-18-2019 17:00
    Chai:

    It looks like the data you are attempting to grab is somehow not recognizable. I would like to help further but, we would need to take a closer look at the data set you are attempting to access, so we would need to make a Support ticket. You are using an email account on the Community which I cannot use to authenticate which customer you are. I would suggest going to one of your Jama Named Support Contacts and ask if they can make a ticket for you.

    Thank you,

    ------------------------------
    Chloe Elliott
    Jama Software
    Portland OR
    ------------------------------



  • 8.  RE: Unable to update jama item using PUT rest api and curl

    Posted 07-18-2019 18:07
    Hi Chai,

    I was able to update the description of an item in swagger using the "PATCH /items/{id} endpoint and the op "replace". Here is the body I used:

    [
    {
    "op": "replace",
    "path": "/fields/description",
    "value": "this is a test"
    }
    ]

    This gives the CURL:

    curl -X PATCH "https://<URL>/rest/latest/items/<item#>" -H "accept: application/json" -H "Content-Type: application/json" -H "jama-csrf-token: <token>" -d "[ { \"op\": \"replace\", \"path\": \"/fields/description\", \"value\": \"this is a test\" }]"

    If you replace the < > information, this should work for you.

    Good luck!

    Jason



    ------------------------------
    Jason Ritz
    Jama Software
    OR
    ------------------------------



  • 9.  RE: Unable to update jama item using PUT rest api and curl

    Posted 07-18-2019 19:48
    Edited by Chai P 07-18-2019 19:56
    Hi

    How do I get the token  in jama-csrf-token: <token>?

    Is it mandatory to pass  jama-csrf-token: <token> in curl. Could that be ignored and still the curl would update the item for me?

    I am new to Jama , so  not sure how the csrf token is generated. I want some one to help me understand swagger and curl response generation so that  I can start automation of tasks in jama using rest api. So  please
    kindly help

    Also,

    Could anyone help me how to learn swagger and generate curl response. I am ready to pay if needed

    Thanks
    Chaitanya

    ------------------------------
    Chai P
    aaa
    ------------------------------



  • 10.  RE: Unable to update jama item using PUT rest api and curl

    Posted 07-19-2019 11:33
    Chai:

    How to get a token:

    First go into your instance of Jama and click on your name.

    click on Set API credentials:

    Should lead you to this window:


    This will generate a client ID and a coordinating client secret which will give you access. Here are instructions from our Developer docs as well.

    This should work as the csrf token.

    I linked you to our documentation for our REST api, and you mentioned wanting more direct help and possibly some tutoring. Our Professional Services does offer tutoring on the REST api, feel free to reach out to your Jama Software Account Manager to see how we can set this up for you!

    Best,


    ------------------------------
    Chloe Elliott
    Jama Software
    Portland OR
    ------------------------------



  • 11.  RE: Unable to update jama item using PUT rest api and curl

    Posted 24 days ago
    Hi Chole

    I am not able to see the option of set api credentials for my profile. So how can I get the token?​

    ------------------------------
    Chai P
    aaa
    ------------------------------



  • 12.  RE: Unable to update jama item using PUT rest api and curl

    Posted 20 days ago
    Chai:

    It is sounding more and more, to me, like your instance may not be authorized to use the REST api, if you are a Cloud customer with us then you are going to want to ask your Organizational Administrator to put in a ticket directly with our Support team to turn on access. We will need one of your Named Support Contacts to authorize this. Or if you have a Self-Hosted instance you will need to ask whoever has the System Administrator role to authorize this access for you.

    Best,

    ------------------------------
    Chloe Elliott
    Jama Software
    Portland OR
    ------------------------------



  • 13.  RE: Unable to update jama item using PUT rest api and curl

    Posted 13 days ago
    Edited by Chai P 13 days ago
    Hi

    I am able to get the output of GET request. So if rest api is not configured correctly this should also not work. Correct me if my understanding is wrong.

    Below is the curl command used

    curl -u xxx:yyyyy -X GET --header "Accept: application/json" "https://brg-jama-tst.state.mi.us/rest/latest/abstractitems?project=45&itemType=128&maxResults=50" >testingBR.json​


    Also how to check if the rest api is configured and enabled correctly in Jama and mine is a Self-Hosted instance and what role should the system admin  authorize this access for you. I have creator license role

    ------------------------------
    Chai P
    aaa
    ------------------------------



  • 14.  RE: Unable to update jama item using PUT rest api and curl

    Posted 24 days ago
    Hi Jason

    I tried with the curl you provided, still it gives me below error and I am not able to update the description field

    Below is the curl command I am using


    curl -u pottic:July2019# -X PATCH "https://brg-jama-tst.state.mi.us/rest/latest/items/10276" -H "accept: application/json" -H "Content-Type: application/json" -H -d "[ { \"op\": \"replace\", \"path\": \"/fields/description\", \"value\": \"this is a test to update\" }]"


    error is as below :


    {"meta":{"status":"Bad Request","timestamp":"2019-07-26T18:06:13.089+0000","message":"the request violated certain constraints","violations":[{"message":"request body is required","constraint":"BODY_NOT_NULL"}]}}

    curl: (3) [globbing] bad range specification in column 2



    Thanks
    Chaitanya​

    ------------------------------
    Chai P
    aaa
    ------------------------------



  • 15.  RE: Unable to update jama item using PUT rest api and curl

    Posted 13 days ago
    Hi Chai,

    It looks like you have an extra -H before the data (-d) field, so the CURL thinks the "body" is part of the header. Other than that your CURL looks good. Try:

    curl -u pottic:July2019# -X PATCH "https://brg-jama-tst.state.mi.us/rest/latest/items/10276" -H "accept: application/json" -H "Content-Type: application/json" -d "[ { \"op\": \"replace\", \"path\": \"/fields/description\", \"value\": \"this is a test to update\" }]"


    Let me know if that works for you. Also, can you tell me why you are using a CURL instead of the UI or Swagger? I may have other solutions for you.

    Thanks,
    Jason


    ------------------------------
    Jason Ritz
    Jama Software
    OR
    ------------------------------



  • 16.  RE: Unable to update jama item using PUT rest api and curl

    Posted 11 days ago
    Hi json

    The above worked. Please let me know how to use Swagger to update Jama items I am new to it.  my requirement is that I have multiple BR and I want to update the description  field for all requests . How is it possible to do that automatically with Swagger in one go if there is a key word present for it.

    ------------------------------
    Chai P
    aaa
    ------------------------------



  • 17.  RE: Unable to update jama item using PUT rest api and curl

    Posted 10 days ago
    Hi Chai,

    Swagger would only be able to update one item at a time. To accomplish what you want to do I would recommend writing a script to automate the process. I prefer Python for jobs like these, but you can use the language of your choice to interact with our REST API. I would recommend using the "GET abstractitems" endpoint to get all of the items that need to be updated. This endpoint allows you to filter the results so you can retrieve only the items you want to update. Then you could use the "PATCH items/{id}" endpoint for each retrieved item to update the description field.

    If the API is enabled in your Jama instance you can access swagger by logging into Jama and navigating to "<Base URL>/api-docs". You can find information on our REST API at the following links:
    https://dev.jamasoftware.com/api/#overview
    https://dev.jamasoftware.com/

    I hope that helps,
    Jason

    ------------------------------
    Jason Ritz
    Jama Software
    OR
    ------------------------------



  • 18.  RE: Unable to update jama item using PUT rest api and curl

    Posted 10 days ago
    Chai:

    Also, if you find that you want to use the UI, you can easily update items in Jama by doing an Excel Round-Trip Export. I linked the page to the user guide in this message, take a look!

    Best,

    ------------------------------
    Chloe Elliott
    Jama Software
    Portland OR
    ------------------------------