Author |
Message
|
birger.r |
Posted: Thu Sep 25, 2014 7:35 am Post subject: HTTP Request Node / Post request |
|
|
Novice
Joined: 22 Jun 2010 Posts: 10
|
Hi all,
I am trying to invoke a REST-ful API by using the HTTP Request Node. I am using WMB 8.0.0.4 on RHEL.
I need to send POST data to this service, but it appears I am not able to do it.
My code looks as follows:
FLOW: MQ Input -> Compute -> HTTP Request -> Compute -> MQ Output
(Compute mode = Local Environment and Message)
ESQL-snippet of first copute node
Code: |
SET OutputLocalEnvironment.Destination.HTTP.RequestLine.Method = 'POST';
Set OutputRoot.HTTPRequestHeader."Content-Type" = 'application/x-www-form-urlencoded';
SET OutputLocalEnvironment.Destination.HTTP.QueryString.key1 = "value1"; -- Multiple key values pairs are set in the code
SET OutputLocalEnvironment.Destination.HTTP.RequestURL = requestURL;
|
If I am checking what is sent by message broker, I can see all key-value pairs are sent, but not as POST parameter, but as part of the query. The web service I am trying to invoke needs the parameters as Part of the POST request, not as part of the Query- String. Any chance to get this working?
I am using requestb.in to check my HTTP-Requests - if that is of any help.
I have tried to set the POST data as body of the message (as BLOB) - I can see this is sent as Body, but this does not help, too.
Any hint is highly appreciated.
Cheers, Birger. |
|
Back to top |
|
 |
Tibor |
Posted: Thu Sep 25, 2014 7:44 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
Maybe a dumb question, but did you set the LocalEnviroment tree for propagation? |
|
Back to top |
|
 |
birger.r |
Posted: Thu Sep 25, 2014 7:49 am Post subject: |
|
|
Novice
Joined: 22 Jun 2010 Posts: 10
|
Yes - I can see that the settings are set and the key-value pairs exist at the receiving site. But their are set at the wrong place. (They are part of the query, but not part of the POST data.) |
|
Back to top |
|
 |
Tibor |
Posted: Fri Sep 26, 2014 1:45 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
It is very interesting, because HTTPRequest should use POST as a default method by the manual.
Is there any other option for checking your request? Perhaps you could start message flow with an HTTPInput and a Trace node. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Sep 26, 2014 4:43 am Post subject: Re: HTTP Request Node / Post request |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
birger.r wrote: |
I have tried to set the POST data as body of the message (as BLOB) - I can see this is sent as Body, but this does not help, too.
Any hint is highly appreciated.
Cheers, Birger. |
Did you try to send it as part of the body as XML as well?
What was the content of your BLOB?
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Sep 26, 2014 5:13 am Post subject: Re: HTTP Request Node / Post request |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Can someone remind me of what this is supposed to do?
Code: |
Set OutputRoot.HTTPRequestHeader."Content-Type" = 'application/x-www-form-urlencoded'; |
I've forgotten some of my niceties of HTTP rules. |
|
Back to top |
|
 |
akil |
Posted: Sun Oct 26, 2014 9:13 am Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
application/x-www-form-urlencoded encodes the name value pairs as a query string in the POST body.
Something like the following
Code: |
POST /test/demo_form.asp HTTP/1.1
Host: w3schools.com
name1=value1&name2=value2
|
Note the key-value pairs are like a query-string..(url encoded) _________________ Regards |
|
Back to top |
|
 |
mgk |
Posted: Sun Oct 26, 2014 10:54 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
WMB/IIB does not currently help when constructing 'application/x-www-form-urlencoded' messages. You will need to construct the message using the BLOB parser. Please raise a requirement if you think this would be useful...
Kind regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
Cubersome |
Posted: Tue May 19, 2015 7:51 am Post subject: |
|
|
Apprentice
Joined: 02 Mar 2012 Posts: 37
|
Hi Mgk,
Could you please let me know is the following requirement possible in WMB 8.0.0.4
Requriement Details:
--------------------------
I want to send large payload as part of the HTTP POST and as a QueryString but not in the URL.
I want something like
HTTP POST http://ABC URL
content type - 'application/x-www-form-urlencoded';
Then entire query string as part of the body. Not along with the URL
Currently HTTP Request node with POST is sending as
http://ABC URL?key1=value
I want key1= value as part of the body but as a query string.
In SOAP UI we have a check box option for HTTP Test Request to post the QueryString parameters as part of the body. Can the same behavior available in WMB? |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed May 20, 2015 4:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Reopening quite an old post here...
Did you try following mgk's advice and post the information not as a query string but URL encode it and post it as a BLOB?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Cubersome |
Posted: Wed May 20, 2015 5:11 am Post subject: |
|
|
Apprentice
Joined: 02 Mar 2012 Posts: 37
|
Hi fjb_super,
The first thing I have done is posting the body as BLOB but the receiving application is not able to intercept the message because of XML special characters. When I am sending the data as QueryString it is able to intercept the message correctly with XML special characters.
When the payload is too big all the data is going with the URL and we do have some length constraints set for the HTTP header size.
So that's the reason I am trying to send the payload as Query String as part of the body. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed May 20, 2015 5:21 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
well the thing is you have to URL encode it first. Just sending the query string as blob apparently won't do it... Best suited for URL encoding would probably be a java compute node or a static java function with an ESQL call out ...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Cubersome |
Posted: Wed May 20, 2015 5:46 am Post subject: |
|
|
Apprentice
Joined: 02 Mar 2012 Posts: 37
|
Hi fjb_saper,
Below is the detailed explanation:
Code: |
SET aHost = SUBSTRING(SUBSTRING(xxURL AFTER 'http://') BEFORE '/');
SET aPOST = SUBSTRING(xxURL AFTER aHost) || '?';
SET OutputRoot.HTTPRequestHeader.POST = aPOST;
SET OutputRoot.HTTPRequestHeader.Host = aHost;
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'application/x-www-form-urlencoded';
SET OutputLocalEnvironment.Destination.HTTP.RequestURL = xxURL;
SET OutputLocalEnvironment.Destination.HTTP.QueryString.Key = SUBSTRING(ABC_Message AFTER 'Key=');
|
In the above case the message populating out of the Compute Node is
Properties,
HTTP Request Header
and Under the Local Environment Query String is getting populated with the entire data.
And if I comment the below line of code:
Code: |
--SET OutputLocalEnvironment.Destination.HTTP.QueryString.Key = SUBSTRING(ABC_Message AFTER 'Key=');
--And sending as
SET OutputRoot.BLOB.BLOB = CAST(cTempMsg AS BLOB CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding);
|
In the above case the message populating out of the Compute Node is
Properties,
HTTP Request Header
BLOB with the entire data
So If I put a java compute node or static Java function the data will be encoded but the way it sent out will remains as above.
Please let me know If I am missing anything
Also thanks a lot for your valuable inputs. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed May 20, 2015 6:00 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Cubersome wrote: |
The first thing I have done is posting the body as BLOB but the receiving application is not able to intercept the message because of XML special characters. When I am sending the data as QueryString it is able to intercept the message correctly with XML special characters. |
And you did not think this problem was due to the fact that your QueryString was not URL encoded when sending it as a BLOB?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Ksawery |
Posted: Mon Jul 08, 2024 12:31 am Post subject: POST method using HTTP Request |
|
|
Newbie
Joined: 12 Oct 2022 Posts: 6
|
I also had the same problem. Attempts to send a message to the web service ended with an ERROR stating "no content to map to the object due to the end of input data". I had the code correctly written in the Compute node, the properties of the HTTP Request node itself were also - it seemed to me - set correctly. And the error came again and again. In my case, however, the problem was leaving one property of the HTTP Request node as default. It's about the property in the 'Advance' tab, called 'Use whole input message as request'. Here you have to uncheck, and in 'Request message location in tree' indicate the full path just to the message to be found as payload. And then it went without a problem. I hope you find this useful too! |
|
Back to top |
|
 |
|