Brian Dunning's FileMaker Custom Functions

httpResponseCode ( responseHeaders )

Retrieves the last HTTP Response Code from the Response Headers

  Average rating: 4.0 (3 votes) Log in to vote

Andrew Duncan   Andrew Duncan - Show more from this author
Databuzz
https://www.databuzz.com.au

Share on Facebook Share on Twitter

  Sample input:
httpResponseCode ( "HTTP/1.1 200 OK
Date: Wed, 13 Jun 2018 04:45:17 GMT
Server: Apache/2.4.26 (Red Hat)
X-Powered-By: PHP/5.6.35
Transfer-Encoding: chunked
Content-Type: application/json; charset=UTF-8" )
  Sample output:
200

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

When working with APIs you often need to check the HTTP Response Code to confirm the request was successful. By passing in the Response Headers from your HTTP request this function will return the last response code found in the Response Headers. For example when using the native cURL options in FileMaker Pro v16 and later:

" --dump-header $responseHeaders"

If more than one response code is returned it will return the last response code from the Response Headers.

N.B. this function requires the Trim4 custom function

 

Comments

Daniel   Daniel
Feb 5, 2021
Thanks this was a quick fix when I started encountering multiple HTTP response codes.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: