cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an API Endpoint to attach a file to a specific quote?

vrjadhav
Participant
0 Kudos
540

We are attempting to upload a file (pdf/jpg) from a public URL to CPQ. We are aware of the API {{url}}/Cart/UploadCartAttachment, but this attaches the document to the quote set in context.

Is there an API or method that allows us to attach a document/file to a quote with a specific quote ID? 

Additionally, could you suggest how to call "/Cart/UploadCartAttachment" using a Python scripting REST client?
We have been using `requests.post(url, file)` and passing a byte array, but it does not seem to work. 

Thank you,
Vaibhav Jadhav

Accepted Solutions (1)

Accepted Solutions (1)

Fancy_Zou
Product and Topic Expert
Product and Topic Expert

Hi @vrjadhav ,

The API to facilitate the integration for uploading attachments to a quote in a customer project has not been officially published. However, the /Cart/UploadCartAttachment endpoint is utilized by the standard CPQ UI frontend for user interaction execution. This is a stateful API and relies on the X-CSRF-Token for quote context.

To invoke this API via your custom scripts, you'd need to obtain an X-CSRF-Token initially from an open target quote. Considering the different implementation approaches:

  • With API invocation through a Custom Responsive Template, you could directly retrieve the cookie information with the X-CSRF-Token from the user session.
  • If you're calling the API asynchronously like custom background jobs or external system integration, you'd first need to emulate user login via /api/rd/v1/Core/LogIn and open the target quote in Edit mode via /api/rd/v1/QuoteList/ExecuteAction. Remember, it is essential to use the same X-CSRF-Token across the process flow when invoking the stateful APIs to ensure all operations are based on the same quote context.

With respect to your specific use case, I recommend submitting an enhancement request in SAP CPQ | Customer Influence Portal to the SAP CPQ product team. This way, the development team can thoroughly analyze your business case and consider any possible recommendations or future improvements to better support your needs.

Best Regards.
Fancy

Andrzej97
Explorer
0 Kudos

Hi, looks like the solution is not working anymore, recently SAP introduced new 'feature':

"The UploadCartAttachment API (/Cart/UploadCartAttachment) has been updated. SAP CPQ has introduced AntiForgery validation for this API for security reasons. Now, when a user uses the drag and drop functionality for the Attachments feature on the Documents Tab of a Quote, SAP CPQ will send an additional token, "RequestVerificationToken," to ensure complete security. If the API is being used, it is important to ensure that the token is sent correctly in the headers with this request.' See link: 

https://searchtest.hana.ondemand.com/whats-new/35009742129b4f45851a5b47a3ddd413?q=upload&locale=en-U...

Do you know how I can obtain "RequestVerificationToken" so i can pass to the header while making a request?

 

Answers (1)

Answers (1)

Andrzej97
Explorer
0 Kudos

Remember when doing upload via postman, it is important to pass to file as form-data in body, i tried to send this as raw and it didn't work. This note can help as well https://userapps.support.sap.com/sap/support/knowledge/en/3417551