HTTP headers

retgits
retgits Member Posts: 5

With Solace Cloud, is there a way to get the HTTP headers in my message too? I realize that the HTTP option gives me the complete payload in my message but I wasn’t able to figure out from the docs how I can get the HTTP headers from the request into my message. In some of my cases (or at least where I’d love to use it for) the HTTP headers have information I’d need

Best Answer

Answers

  • [Deleted User]
    [Deleted User] Posts: 0 ✭✭

    @retgits said:
    I realize that the HTTP option gives me the complete payload in my message

    Can you provide a bit more information on what you're trying to do here? "the HTTP option", are you referring to REST?

  • retgits
    retgits Member Posts: 5
    edited June 2019 #4

    Yup, I'm indeed looking at the REST API and working through the REST example (https://docs.solace.com/Open-APIs-Protocols/REST-get-start.htm). When I use the "try me!" option in the UI as a subscriber to my topic called "try-me" and use a cURL command to send a message

    curl -X POST https://<host>:<port>/try-me \
    -d "Hello World REST" \
    -H "content-type: text" \
    -H "Solace-delivery-mode: direct" \
    --user <user>:<password> --header "MyHeader:x"
    

    I can't find the correct way to let it also display the header called "MyHeader" (it does display the body correctly)

  • retgits
    retgits Member Posts: 5

    I've figured out a few things, but I'm still a little stuck so help is still appreciated :smile:
    After reading through some more docs, I realized that my instance was in messaging mode and I had to switch that to gateway mode. After that, and realizing I couldn't use the MQTT client anymore, I was able to get the header parameter using the statement message.getUserPropertyMap().getField("JMS_Solace_HTTP_field_<header name>"). I've taken the TopicSubscriber.js and modified it to my needs. My only issue now is that the gateway assumes there will be a reply and I don't know how to configure that (or how to configure no reply is needed). The response I get from my cURL command is:

    < HTTP/1.1 504 Reply Wait Timeout
    < Cache-Control: no-cache
    < Content-Length:  263
    < Content-Type: text/xml
    < Server: Solace_PubSub+_Enterprise/8.13.1.31
    < Set-Cookie: TSID=<>; Path=/
    < Solace-Client-Name: #rest-<>
    <
    <solace-error-response>
    <code>504</code>
    <reason><![CDATA[Reply Wait Timeout]]></reason>
    <detail><![CDATA[
    Timed out waiting for reply after 30001ms; Solace-Reply-Wait-Time=30000ms
    ]]></detail>
    <internal-use>1:7422</internal-use>
    </solace-error-response>
    * Connection #0 to host <>.messaging.solace.cloud left intact
    
  • [Deleted User]
    [Deleted User] Posts: 0 ✭✭

    Thanks for the updated info - let me do some checking and I will get back with you.

  • retgits
    retgits Member Posts: 5

    I also made a quick write-up of how I configured everything and the use case I needed this for :smile:https://retgits.com/2019/06/how-to-get-webhooks-into-your-system-using-solace-pubsub-cloud/