Add HTTP Status to responsedata

Hi Alumio,

In some cases you need to request an entity from an API which would return a 404 when the entity doesn’t exist. The HTTP Client option to allow ‘status 404’ works great for this, but I’m running into one issue: I have no ability to actually “see” that it’s a 404 I’m getting.

Currently I’m validating based on the response body (this api gives back “detail”: “Not found.”), but I don’t really like doing it like this.

The HTTP-transformer already has the option to “Add headers to response body”. It would be great if the HTTP status code is added to the headers, or added into another node with more data about the response. That way, I could really check correctly what the response was.

Thanks!

Hi Floris,

We apologize for overlooking this post. We are currently improving our procedure for handling forum topics, and hopefully, we will not miss any questions from forum users in the future.

Could you please confirm whether you expect to be able to validate “404” as the HTTP status code instead of a string message returned by the API?

Hi Gugi,

Ok, in practice my question is as follows:

Currently when you use an HTTP transformer (or the equivalent in an incoming), you can click the ‘add headers to response body’. This adds the headers, giving you something like this:

{
  "headers": {
    "Date": [
      "Wed, 27 Nov 2024 09:59:40 GMT"
    ],
    "Content-Type": [
      "application/json"
    ],
    "Content-Length": [
      "570"
    ],
    "Connection": [
      "keep-alive"
    ],
    "Server": [
      "gunicorn/19.9.0"
    ],
    "Access-Control-Allow-Origin": [
      "*"
    ],
    "Access-Control-Allow-Credentials": [
      "true"
    ]
  },
  "data": {
    "responseFromApi": "test"
  }
}

That’s useful, but what if I need to check what the actual response-status-code was? The headers don’t help me with this, since they don’t give a ‘http-status’ or anything.

So what if the same ‘Add headers to response body’ could return this?

{
  "http_status": {
    "status_code": "200",
    "status_message": "Accepted"
  },
  "headers": {
    "Date": [
      "Wed, 27 Nov 2024 09:59:40 GMT"
    ],
    "Content-Type": [
      "application/json"
    ],
    "Content-Length": [
      "570"
    ],
    "Connection": [
      "keep-alive"
    ],
    "Server": [
      "gunicorn/19.9.0"
    ],
    "Access-Control-Allow-Origin": [
      "*"
    ],
    "Access-Control-Allow-Credentials": [
      "true"
    ]
  },
  "data": {
    "responseFromApi": "test"
  }
}

This would allow you to check within the following transformers if you’ve got the expected status code.

A particular example of why I’d need this is APIs which don’t (or with too limited options) allow for filtering on a list. So let’s say I’d need to check whether a product exists - normally I’d do something like /products?filter=sku eq 'ABC', and check the result array to see if the product exists. However, if I can’t filter, maybe I need to do this: /products/ABC. This would return a 404 if it doesn’t. That’s not a problem, in the Client we can accept a 404. However, there’s now not a “good” option (you can do stuff like ‘key exists’, but that’s just ugly) to check the response status code.

Hi Floris,

Thank you for the thorough explanations.

We will pass your feedback on to the corresponding team to check further on the possibility of adding an option (or extending an existing option) to return the HTTP response status to the entity.

Please kindly wait for any updates.

Hi @floris,

We’re pleased to let you know that your feature request has been approved and added to the upcoming sprint! If all goes well, it will be available in UAT on January 7th, 2025, and in production on January 21st, 2025.

You can subscribe to our Release Notes page to get updates on new releases, including this feature.

1 Like