YOUSEFUL / FILEMAKER
Youseful HTTP: FAQ, examples and tutorial
Learning center · Function reference
Use YsflHttp.fmx64 for REST, GraphQL, uploads and downloads through Windows
WinHTTP. The short examples work offline; the tutorial needs your own read-only
test endpoint returning JSON.
FAQ
Is HTTP 404 a transport failure? No. The server can successfully return a 404 response. Save LastError immediately after the request, then Status and the body. Handle non-2xx status codes in your application.
When should I choose Curl instead? HTTP covers the common REST and GraphQL workflow. Curl adds options such as HTTP/2 negotiation, cookie jars, transfer statistics and additional URL protocols. See the Curl guide.
How are options separated? Use spaces or paragraphs. Headers and some other
values consume the rest of their line, so put them on separate lines. For example,
"timeout=15¶header=X-Demo: Youseful¶accept=application/json".
Can Get return an image or PDF? Use GetContainer for binary content and Download for a file on disk. Get is the text-oriented function.
Examples
Encode one query-parameter value:
YsflHt_URLEncode ( "a b&c" )Result: a%20b%26c. Encode values, rather than an entire URL containing separators.
Read a URL host without connecting:
YsflHt_ParseURL ( "https://api.example.com:8443/items?id=7" ; "host" )Result: api.example.com.
Tutorial
Standalone sample scripts: Fetch JSON.
Goal: fetch JSON while distinguishing transport failure from HTTP failure.
- Choose a read-only test endpoint you control or are allowed to call. This script expects a 2xx JSON response. Replace the example URL before running it.
- Create
Youseful - Fetch JSON:
Set Variable [ $url ; Value: "https://api.example.com/demo.json" ]
Set Variable [ $body ; Value: YsflHt_Get ( $url ; "timeout=15¶accept=application/json" ) ]
Set Variable [ $transportError ; Value: YsflHt_LastError ]
Set Variable [ $transportMessage ; Value: YsflHt_LastErrorText ]
Set Variable [ $status ; Value: YsflHt_Status ]
If [ $transportError <> 0 ]
Show Custom Dialog [ "Connection failed" ; $transportMessage ]
Exit Script [ Text Result: $body ]
End If
If [ $status < 200 or $status >= 300 ]
Show Custom Dialog [ "HTTP " & $status ; $body ]
Exit Script [ Text Result: $body ]
End If
Set Variable [ $formatted ; Value: JSONFormatElements ( $body ) ]
If [ Left ( $formatted ; 1 ) = "?" ]
Show Custom Dialog [ "Response is not JSON" ; $body ]
Else
Show Custom Dialog [ "HTTP " & $status ; $formatted ]
End If- Run it. With an endpoint serving
{"message":"Hello"}, expect an HTTP 200 dialog containing that JSON. Exact status and data depend on your endpoint. - Request a missing resource on your test server to exercise the HTTP-error branch. Status must be captured before a later request overwrites it.
For a bearer-protected endpoint, add "¶bearer=" & $token to the options after
obtaining the token through your application's authentication flow.
Troubleshooting
Capture errors before Status: Status itself clears LastError. An empty successful 204 response is valid HTTP but is not JSON, so adapt the final branch for that API. For certificate failures, fix the certificate or trust configuration rather than disabling verification in the example.