Need confirmation on http:send-request

Wednesday, 12 February 2025 · 2 messages · last reply 13 Feb 2025
ML
Marco Lettere12 Feb 2025 20:21 #
Dear Christian et al, moving to basex 11.7 today I've found out that it is not necessary to serialize the body content in an http-request such as [1]. If I do (as I had to up to Basex 10.7) the body is no longer understood. Now I obtsain correct behaviour when using code as in [2]. Can you confirm this change in behaviour? And if yes, this has a huge impact on the many many http calls we have so maybe it should be documented? Thanks a lot as usual! M. [1]
let $body := json:serialize(<json type="object"/>)
return
<http:request href="url" method="POST">
     <http:body media-type="application/json">{$body}</http:body>
</http:request>
[2]
let $body := <json type="object"/>
return
<http:request href="url" method="POST">
     <http:body media-type="application/json">{$body}</http:body>
</http:request>
MS
Michael Seiferle13 Feb 2025 10:26 #
Dear Marco, This was added in BaseX 11.4 — https://basex.org/2024/10/02/basex-11.4/
Quoted text · Marco Lettere · 1 line
> [FIX] XQuery: better support for JSON payloads in HTTP requests
Sorry if this caused troubles! Best from Konstanz Michael
Quoted text · Marco Lettere · 1 line
Am 12.02.2025 um 20:21 schrieb Marco Lettere <m.lettere at gmail.com>:
Dear Christian et al, moving to basex 11.7 today I've found out that it is not necessary to serialize the body content in an http-request such as [1]. If I do (as I had to up to Basex 10.7) the body is no longer understood. Now I obtsain correct behaviour when using code as in [2]. Can you confirm this change in behaviour? And if yes, this has a huge impact on the many many http calls we have so maybe it should be documented? Thanks a lot as usual! M. [1]
let $body := json:serialize(<json type="object"/>)
return
<http:request href="url" method="POST">
    <http:body media-type="application/json">{$body}</http:body>
</http:request>
[2]
let $body := <json type="object"/>
return
<http:request href="url" method="POST">
    <http:body media-type="application/json">{$body}</http:body>
</http:request>

⚡Generated with XQuery