How do I get the http status code?

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
jasanchez
Posts: 3
Joined: Thu Aug 03, 2023 2:49 am

How do I get the http status code?

Post by jasanchez »

Maybe this is something already answered, sorry if so.
I just need to know how to always get the status code returned by the server.

Is it with http_header() or with http_error()?

TIA
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: How do I get the http status code?

Post by Scott Klement »

You can receive it by passing the appropriate parameter to http_error.

Or, you can just receive it as the return value from http_req, http_url_post_xxx, http_url_get_xxx, etc. They return any response code EXCEPT 200 -- instead of 200 they return 1 instead... so you can just say "if code=1; eval code=200; endif" or whatever, and you'll have the return code.
Post Reply