Technical Articles
Update commodities in a questionnaire via the SAP Ariba APIs
In this blog post I quickly explain how to update the commodities of a commodity type question in a supplier questionnaire.
In the Supplier Data API with Pagination documentation – https://help.sap.com/viewer/60ec8b8bb9344dbe8dcf15e2a1edc85b/cloud/en-US/ade8c980937c4684a8cffeec7143728d.html, it is possible to find details on how to update answers to questions. Unfortunately, it only covers answers to simple questions and attachment type questions but what about commodity type questions?
If you want to learn how to update certificate type questions, check out this blog post – https://blogs.sap.com/2021/11/15/update-certificate-type-questions-via-the-sap-ariba-apis/
So, how do I update commodity questions in a supplier questionnaire?
To have an idea of the body structure required by the API for a certificate type question, I used Chromium Developer tools and captured the request sent when updating the question. Within the request I extracted the item that belongs to the commodity type question and used that as a starting point.
Chromium developer tools – submitQuestionnaire
There are limitations on when you are able to update the answers of a questionnaire, e.g. can’t update an answer in any questionnaire that the supplier is currently acting on, make sure you are familiar with them. You can find the limitations here: https://help.sap.com/viewer/60ec8b8bb9344dbe8dcf15e2a1edc85b/cloud/en-US/ade8c980937c4684a8cffeec7143728d.html
Below a sample request to update a commodity type question. Notice that we need to commodity Id and “pack them” in an array as it is a field that allows multiple values.
curl --location --request POST 'https://openapi.ariba.com/api/supplierdatapagination/v4/prod/vendors/S350261234/workspaces/questionnaires/Doc3244061234/answers?realm=myrealm-T' \
--header 'Content-Type: application/json' \
--header 'apikey: S9f5ap58UGqw9f5a8ANamn9f5aUEg9f5a' \
--header 'Authorization: Bearer 0bad03e4-1234-1234-6789-f2f835065be1' \
--data-raw '{
"answers": [
{
"externalSystemCorrelationId": "KI_1211234",
"multiValueAnswer": [
"53",
"72"
]
}
]
}'
Once updated, we can retrieve the values via the API and there we will see the answers just posted to the API.
Commodity type question updated via API
I hope this quick blog post helps you when battling with the Supplier Data API with Pagination when trying to update commodity type questions :-).
Hi Antonio,
Thanks for this wonderful info.
For our client we tried to updating "commodity" code value in Supplier Request form but getting error. do you have any idea what would be the issue.
"Error executing the request: S4 error ID: 22008501508791. --- Internal Server error. S4 user message: Questionnaire Response is not editable."
using below curl command
curl -X POST \
'https://openapi.ariba.com/api/supplierdatapagination/v4/prod/vendors/S39959186/workspaces/questionnaires/Doc3347370815/answers/?realm=EYAribaDemo' \
-H 'apikey: htzXKmE9SOhTx378tkO3wYmSvC0xTKoG' \
-H 'authorization: Bearer ac6481d4-0a28-4422-ac68-15fab3028275' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: 952a4c10-e974-3e53-7f59-fe95e3af2b7b' \
-d '{
"answers": [
{
"externalSystemCorrelationId":"KI_12452448",
"multiValueAnswer":["531030"]
}
]
}'
Hi Karthiga Ravichandran
There are some conditions under which you are able to update a questionnaire question. See the table included in the documentation - https://help.sap.com/viewer/60ec8b8bb9344dbe8dcf15e2a1edc85b/cloud/en-US/ade8c980937c4684a8cffeec7143728d.html?q=%22currently%20acting%20on%22. It is possible that the answers you are trying to update doesn't fit the criteria.
Also, check the HTTP status code returned by the API, that will give you some hints as well.
Hello Antonio,
Thanks for prompt reply, the supplier which we are trying to update the value is in "Registered" status and we are trying to update value of Commodity code field on Supplier Request form. Is that possible to update field value in Supplier Request form
Thank you!!
Karthiga
I believe it is not possible to update the supplier request form.
Thank you Antonio.
Hello Antonio,
Karthiga again :)!! We trying to update the question of "Yes/No" answer type using below body message and it is not updating. can you help me?