Changes

Jump to navigation Jump to search
180 bytes removed ,  18:32, 1 December 2023
m
Text replacement - "</syntaxhighlight>" to "</pre>"
'''Query:'''
<pre lang='xquery'>http:send-request(<http:request method='get' status-only='true'/>, 'http://basex.org')</syntaxhighlightpre>
'''Result:'''
<syntaxhighlight lang="xml"><http:response status="200" message="OK">
<http:header name="Cache-Control" value="max-age=90"/>
<http:body media-type="text/html; charset=utf-8"/>
</http:response></syntaxhighlightpre>
==Google Homepage==
'''Query:'''
<pre lang='xquery'>http:send-request(<http:request method='get' href='http://www.google.com' timeout='10'/>)</syntaxhighlightpre>
'''Result:'''
<syntaxhighlight lang="xml">
</body>
</html>
</syntaxhighlightpre>
The response content type can also be overwritten in order to retrieve HTML pages and other textual data as plain string (using {{Code|text/plain}}) or in its binary representation (using {{Code|application/octet-stream}}). With the {{Code|http:header}} element, a custom user agent can be set. See the following example:
'Conversion to XML failed: ' || $err:description
}
</syntaxhighlightpre>
===SVG Data===
'''Query:'''
<pre lang='xquery'>http:send-request(<http:request method='get'/>, 'http://upload.wikimedia.org/wikipedia/commons/6/6b/Bitmap_VS_SVG.svg')</syntaxhighlightpre>
'''Result:'''
</linearGradient>
...
</svg></syntaxhighlightpre>
==POST Request==
</query>
)
</syntaxhighlightpre>
'''Result:'''
<div>Section 3</div>
</html>
</syntaxhighlightpre>
==File Upload==
file:read-binary($path)
)
</syntaxhighlightpre>
'''RESTXQ service:'''
});
};
</syntaxhighlightpre>
==Response Conversion==
<pre lang='xquery'>
http:send-request(<http:request method='GET' href='http://localhost:8080/json' json='format=xquery,lax=true'/>)
</syntaxhighlightpre>
'''Result:'''
<syntaxhighlight lang="javascript">
map { "abcde": 12345 }
</syntaxhighlightpre>
Without the {{Code|json}} attribute, the response body is converted to the default XML representation:
<abcde>12345</abcde>
</json>
</syntaxhighlightpre>
'''RESTXQ service:'''
map { 'abcde': 12345 }
};
</syntaxhighlightpre>
See the [[CSV Module]], [[JSON Module]] and [[HTML Module]] for a list of the available options.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu