on 2022 Aug 03 1:05 AM
Dear Experts,
Greetings!
I am building chatbot interaction in SAP CAI.
I am reusing api designed for fiori use and need to make $batch call to get required data from SAP. This $batch returned lots of addition $batch call related information besides json response contained in it. I am not able to use this $batch call response using syntax {{api_service_response.default.body.d.fieldname}}. How to use STATUS field value from $batch call response. Highly appreciate your help in making this work.
Thank you in advance.
Nilesh
my $batch call response is like this:
--0019833333333
Content-Type: multipart/mixed; boundary=00198C6D80DA8DAD05DA0CBAD2C2FBF01
Content-Length: 3104
--00198C6D80
Content-Type: application/http
Content-Length: 7777
content-transfer-encoding: binary
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 7777
dataserviceversion: 2.0
accept: application/json
user-agent: PostmanRuntime/7.28.4
accept-encoding: gzip, deflate, br
b3: 99999999
cookie:
...
...
traceparent: 99999
tracestate: 9999999999
x-b3-spanid: 999999999
x-b3-traceid: 99999999999
x-cf-applicationid: 9999999999
x-cf-instanceid: 999999999999
x-cf-instanceindex: 999
x-dynatrace: FW4;-99999999999999999
x-dynatrace-application: v=2;
x-dynatrace-requeststate: agentId=999999999
x-forwarded-for: 99.999.99.99
x-forwarded-port: 9997
x-forwarded-proto: https
x-request-start: 4466777
x-ruxit-forwarded-for: 177.55.54.55
x-scp-request-id: 55555556677
x-vcap-request-id: 44556666
sap-client: 999
host: dxxxxxx:9999
location: https://dxxxxxx:9999/sap/opu/odata/sap/ZOD_XXXXXXXXX_SRV/SxxxxxSet('--vbeln---')
{“d”:{“__metadata”:{“id”:“https://dxxxxxx:9999/sap/opu/odata/sap/ZOD_XXXXXXXXX_SRV/SxxxxxSet('--vbeln---')”,“uri”:“https://dxxxxxx:9999/sap/opu/odata/sap/ZOD_XXXXXXXXX_SRV/SxxxxxSet('--vbeln---')”,“type”:“ZOD_XXXXXXXXX_SRV.SxxxxxSet”},“IHREZ”:“R0000000346",“VBELN”:“--vbeln---",“AUART”:“FR”,“SELECT”:false,“EBELN”:“”,“LIFSK”:“Released”,“SO_DATE”:null,“IDOC_DATE”:null,“IDOC”:“”,“RCVPRN”:“”,“REC”:“”,“STATUS”:“Action successful Genarated Idoc number : ---idoc no-----”,“SxxxxxToXPUDet”:{“__deferred”:{“uri”:“https://dxxxxxx:9999/sap/opu/odata/sap/ZOD_XXXXXXXXX_SRV/SxxxxxSet('--vbeln---')/SxxxxxToUDet”}}}}}
--00198C6D80--
--0019833333333--
SAP Conversational AI's Consume External Service expects a JSON object back, but if you give something else it will still give you the answer in
{{api_service_response.default.body}}
So you can then do some string manipulation. You could take the string, split it at ["STATUS":], then split it again at the next comma, and take the first value in the list. The start of the coding would be the following, which would give you the start of the data you want: "Action successful Genarated ....
{{itemAt (split api_service_response.test.body "STATUS\":") 1}}
Of course you'd have to be sure of the text format. You could also create a webhook, and there you could do whatever you want to parse the response, and return to the chatbot a message/memory update.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
59 | |
11 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.