Posting Sales Orders into S/4HANA Cloud API – Part 2
This is the second and final post on how to post a sales order with multiple line items into a S/4HANA Cloud (S/4HC) system using the whitelisted Sales Order API. You can read the first blog post here.
In the first blog, we developed and deployed our iFlow. In this blog, we’ll look at how to test /execute the iFlow using Postman app and also take a look the logs generated in the iFlow execution.
Testing the iFlow
Postman is an app by Chrome that is an extremely powerful REST client. In this blog, we’ll use the app to submit a JSON payload to our iFlow endpoint via HTTPS . (Note: Postman is also a great tool to test APIs directly on S/4HC.)
1. Launch Postman and enter the URL of the iFlow HTTPS sender (<tenant url>/http/salesorders)
2. Switch the authorization type to “Basic Auth” and enter your username and password for CPI. (Note the user you are using must have the ESBMessaging.send role on the iflmap tenant)
3. On the Headers tab, enter a new key value “x-csrf-token” and set the value to “Fetch”. (Note: Because we are posting to the API, we need a valid x-csrf-token. You can read more on why in this blog.)
4. Click on the “Send” button to submit the request
5. Even though you get an error in the response payload, when you click on the “Headers” tab in the response section you should see a valid value for x-csrf-token. Copy/paste the x-csrf-token value into the key replacing Fetch.
6. Now switch the method to “Post”
7. Switch to the “Body” tab and set the content type to “raw” and select the payload to be JSON (application/json). Enter your JSON payload for the sales orders.
8. Click Submit to post the data.
9. The response contains the generated sales order details in XML format.
9. The sales order is successfully created in the S/4HC system!
Generated Logs in CPI
Now for a quick look at the data as it moved through the iFlow.
In the beforeMapping step, we can see the generated string object that consists of the line items. This gets added back to the payload after the mapping step occurs.
In the “Payload before Submission” we can see the complete XML with the Sales Order line items in the to_Item block.
And finally, the response payload mirrors what was sent back to Postman.
I hope you found this blog useful!
Great post Marty !
You can also see a similar approach I explored going straight to S4 , by following this link -- > http://pascalrenet.com/2017/12/s4hcks16-taking-pain-integration-design-sap-s-4hana-cloud/
Thanks a lot Marty & Pascal!
Great blog and good starting point for beginners like me!