- From: Matthieu RICAUD-DUSSARGET <m.ricaud-dussarget@lefebvre-dalloz.fr>
- Date: Wed, 1 Nov 2023 12:10:08 +0000
- To: "xproc-dev@w3.org" <xproc-dev@w3.org>
Hi, Back to an xproc dev for a long time, trying xproc 3.0 with last Morgana release, fun :) But have a problem to get the body of a 400 response error, I only manage to get the headers of the response : I off course use a try/catch so the pipeline doesn't break on error. But from within the catch I can't get the result the p:http-request which is not accessible. Let's just explain that the REST API I'm calling give information on the error in the body of the response. For example : { "status": 400, "errors": [ { "received": "toto", "code": "invalid_enum_value", "options": [ "unique", "multiple" ], "path": ["selectionType"], "message": "Invalid enum value. Expected 'unique' | 'multiple', received 'toto'" } ] } My try/catch looks like this : <p:try name="try"> <p:output port="result"> <p:pipe port="result" step="sendFile"/> </p:output> <p:http-request name="sendFile" method="PUT"> <p:with-option name="href" select="'https://my/api/test'"/> <p:with-option name="headers" select="map{'content-type': 'application/json'}"/> </p:http-request> <p:catch> <p:output port="result"> <p:pipe port="result" step="identity"/> </p:output> <p:identity name="identity"/> </p:catch> </p:try> The output of this step is a c:errors containing a map with headers of the response : <c:error code="err:XC0126" name="sendFile" type="p:http-request" href="..." line="56" column="114"> <message>Assert expression '.?status-code lt 400' evaluates to false(). See response transcript below:</message> <map xmlns="http://www.w3.org/2005/xpath-functions"> <number key="status-code">400</number> <map key="headers"> <string key="cache-control">public, max-age=0, must-revalidate</string> <string key="connection">keep-alive</string> <string key="content-type">text/plain;charset=UTF-8</string> <string key="date">Wed, 01 Nov 2023 11:56:15 GMT</string> <string key="server">Vercel</string> <string key="strict-transport-security">max-age=63072000; includeSubDomains; preload</string> <string key="vary">RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url</string> <string key="x-matched-path">/api/[collection]</string> <string key="x-vercel-cache">MISS</string> <string key="x-vercel-execution-region">iad1</string> <string key="x-vercel-id">cdg1::iad1::wsjbl-1698839773942-dcd1ec205f6c</string> <string key="transfer-encoding">chunked</string> </map> <string key="base-uri"> https://my/api/test </string> </map> </c:error> Is there a way to get the body of the response when the API return an error ? I'd like to log the message " Invalid enum value. Expected 'unique' | 'multiple', received 'toto'" from the body Thanks in advance, Matthieu Ricaud-Dussarget Expert XML M. 33(0)6 63 25 95 58 Nouvelle adresse : Tour Lefebvre Dalloz 10 place des Vosges 92400 Courbevoie www.lefebvre-dalloz.fr
Received on Wednesday, 1 November 2023 12:10:19 UTC