Question
Capgemini
IN
Last activity: 16 Oct 2018 12:03 EDT
Connect Rest - Pass Query String Parameters in message body using POST Method in connect rest.
How can we pass Query String Parameters as part of message body using POST Method in connect rest.
***Moderator Edit: Vidyaranjan | Updated Categories***
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
Hi,
The query string parameters will always be a part of resource URI using any method like POST or GET.
However, try setting the request header content-type to "application/x-www-form-urlencoded" which expects a key-value pair (as in query string) with POST method and see if it helps to send string parameters in the request body.
I recommend you to test this approach on your external rest services using REST Api clients like Postman, poster etc.. If it works as expected, we can try implementing this use-case in Pega later.
Let all of us know the outcome.
Thanks!
Capgemini
IN
Hi Harish,
Tried passing the content-type as "application/x-www-form-urlencoded" in Pega but it did not help.
One point : If we use post method then Query String parameter by default should be passed in request body and not in the URI.
scenario - I am passing [ metadata="some attributes in JSON format"] as key value pair i.e. configured as Query String parameters using POST method in connect rest.
When JSON payload is small then I get success response from the service & at the service provider end metadata is received in body and not in the URI.
However when JSON payload is huge then I get below response & request is stopped at web layer itself and metadata is present as parameter in URI.
"<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>414 Request-URI Too Large</title> </head><body> <h1>Request-URI Too Large</h1> <p>The requested URL's length exceeds the capacity limit for this server.
</p> </body></html>"
Thanks!!
Pegasystems Inc.
US
Hi,
Before you implement on the Connect-REST, try using the Postman plugin in chrome to invoke the external rest service.
1. Specify the URL, choose POST method.
2. On body - > Click on x-www-form-urlencoded to specify key-value pair strings and check if it works fine.
Capgemini
IN
Hi Harish,
Tried passing the content-type as "application/x-www-form-urlencoded" in Pega but it did not help.
One point : If we use post method then Query String parameter by default should be passed in request body and not in the URI.
scenario - I am passing [ metadata="some attributes in JSON format"] as key value pair i.e. configured as Query String parameters using POST method in connect rest.
When JSON payload is small then I get success response from the service & at the service provider end metadata is received in body and not in the URI.
However when JSON payload is huge then I get below response & request is stopped at web layer itself and metadata is present as parameter in URI.
"<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>414 Request-URI Too Large</title> </head><body> <h1>Request-URI Too Large</h1> <p>The requested URL's length exceeds the capacity limit for this server.
</p> </body></html>"
Hi Harish,
Tried passing the content-type as "application/x-www-form-urlencoded" in Pega but it did not help.
One point : If we use post method then Query String parameter by default should be passed in request body and not in the URI.
scenario - I am passing [ metadata="some attributes in JSON format"] as key value pair i.e. configured as Query String parameters using POST method in connect rest.
When JSON payload is small then I get success response from the service & at the service provider end metadata is received in body and not in the URI.
However when JSON payload is huge then I get below response & request is stopped at web layer itself and metadata is present as parameter in URI.
"<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>414 Request-URI Too Large</title> </head><body> <h1>Request-URI Too Large</h1> <p>The requested URL's length exceeds the capacity limit for this server.
</p> </body></html>"
Tried in Postman: on body selecting "form-data" it works fine but when i select "x-www-form-urlencoded" it gives error that metadata is missing i.e. it is not being passed.
Thanks!!
Pegasystems Inc.
US
"If we use post method then Query String parameter by default should be passed in request body and not in the URI."
This is one interpretation of a specification, but REST Connector is more open-ended, so there is a clear place to map the "body" versus the parameters in the query string.
The important part of this reply is "Tried in Postman: on body selecting "form-data" it works fine"
Does the endpoint expect a multipart/form-data request?
This could help (it applies to REST but does not say so): https://community.pega.com/sites/default/files/help_v73/procomhelpmain.htm
Capgemini
IN
Yes, its a multipart/form-data request.
As part of request, I am sending "Metadata" as query string Parameter that has value as few attributes in JSON format. And also sending an attachment html file using pyRequestAttachmentPage.
Strange behaviour is when the metadata is small (length = 1k), the query parameters is received in the message body, but, when the metadata is huge (length=17k) , it’s sent as a part of the URL,so now as the request is huge it is being stopped at apache web layer.
Pegasystems Inc.
US
"When the metadata is small (length = 1k), the query parameters is received in the message body, but, when the metadata is huge (length=17k) , it’s sent as a part of the URL."
I agree with you. This is strange behavior.
Unfortunately, I haven't seen this myself (yet), so I do not have advice at the moment.
Wellcare
US