Closed charles-slc closed 1 month ago
Hi @charles-slc, thank you for raising this issue with the documentation. You’re right that the example is wrong - sorry about that. It should be:
- path: "/users"
method: POST
capture:
petName:
store: testStore
requestBody:
xPath: "/env:Envelope/env:Body/pets:animal/pets:name"
xmlNamespaces:
env: "http://schemas.xmlsoap.org/soap/envelope/"
pets: "urn:com:example:petstore"
This would make your config look as follows:
---
plugin: rest
basePath: "/dds"
system:
xmlNamespaces:
soap: "http://schemas.xmlsoap.org/soap/envelope/"
star: "http://www.starstandard.org/STAR/5"
resources:
- path: "/appointments"
method: POST
capture:
serviceappointmentId:
store: requestData
requestBody:
xPath: "/star:ProcessServiceAppointment/star:ProcessServiceAppointmentDataArea/star:ServiceAppointment/star:ServiceAppointmentHeader/star:SecondaryDealerNumberID"
xmlNamespaces:
star: "http://www.starstandard.org/STAR/5"
requestBody:
xPath: "/star:ProcessServiceAppointment/star:ProcessServiceAppointmentDataArea"
operator: Exists
response:
statusCode: 202
content: "appt received"
I’ll keep this issue open until we can fix the docs.
Also need to fix examples:
Thank you! That worked perfectly.
However, I actually just want to capture the entire request body. This seems to do the trick, though using jsonPath
when I dealing with XML feels wrong 😆
capture:
serviceappointment:
store: requestData
requestBody:
jsonPath: $
I tried xPath: $
which threw an error at runtime. Also xPath:"/"
and xPath:"/*"
which didn't throw an error and returned data via the system/stores
REST API, However, the data returned was just the XML data values...no XML tags at all.
And FYI: I asked on SO about this, if you answer there I'll happily accept it. Otherwise in a few days I'll add the answer.
Hi @charles-slc, thanks very much for the update.
Another way to capture the whole body would be using an expression, such as:
capture:
serviceappointment:
store: requestData
expression: "${context.request.body}"
Thanks again, @charles-slc.
Docs and examples updated in v4.0.1
The docs have this example:
But I'm getting
with the following
note if I don't try to capture anything, the xPath match is working just fine.
Actually, what I'm hoping to capture is the entire request body.