I'm trying to figure out HTTParty. I have an endpoint I need to post to.
It won't let me post without setting an X-Correlation-Id according to the Swagger documentation.
I can't see an option in HTTParty to do this.
my current connection attempt is:
uuid = SecureRandom.uuid
url = 'http://localhost:8720/v1/bla'
conn = HTTParty.post(url, body: body.to_json, headers: {'Content-Type' => 'application/json','Authentication' => "Token #{uuid}"})
I keep get an error response from the API stating the X-Correlation-Id is a mandatory field. Is there something obvious I'm missing? Thanks
Pop it into your headers
hash as another entry, the same way you've done for 'Content-Type'
and 'Authentication'
.
Headers which start with X
tend to be custom ones, and so you won't find something built in to most HTTP clients for it, but they all support arbitrary headers like this.