Question

Connect-REST content-type: "application/JSON" not setting in the out going request

In the Connect-REST rule POST header is set to Content-Type: "application/json".

But in the captured Connect REST request has override the header Content-Type with "text/plain" as follows.

Wed Apr 04 03:22:41 CDT 2018:INFO:--8dZGfHO7gPBZCjmgYUr04__I9QM0vQR
Content-Disposition: form-data; name="PostData"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit

{JSON content}

--8dZGfHO7gPBZCjmgYUr04__I9QM0vQR
Content-Disposition: form-data; name="attachments"; filename="Citi_leftmenubar_bg.jpg"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

Note: Connect-REST Request is build with attachments

Is there any other option to set header value as "application/json" apart from adding header in the Connector rule.

***Edited by Moderator Marissa to update Content Type from Discussion to Question; update SR details***

Group Tags

Correct Answer
December 28, 2018 - 6:16am

This issue is a bug in Pega 7.2 code base[SR-C25702]. This is fixed in 8.1 as per the SR update.

So we have removed message data from connector rule and add that JSON part into pyRequestAttachment page as the solution. In there we can provide the content type also as a parameter. And multi-part request also built in the expected format.

Comments

Keep up to date on this post and subscribe to comments

Pega
April 11, 2018 - 11:43am

Could you elaborate on what "Connect-REST Request is build with attachments" means?

Is it supposed to be a Multipart message where one part is the JSON, or did you do custom work to build the JSON out of attachments in some way?

April 16, 2018 - 6:14am
Response to HOULJ

I have used pyRequestAttachmentPage to set attachments to the multi part request. And request contains both attachments and JSON content as follows.

  1. Wed Apr 11 04:02:01 CDT 2018:INFO:--DQTy6UlmvkDsujh7Jv4_2AAvbb-wR9Ato
  2. Content-Disposition: form-data; name="PostData"
  3. Content-Type: text/plain; charset=US-ASCII
  4. Content-Transfer-Encoding: 8bit
  5.  
  6. {"body":"Test%20att%20files%20REST%20email%20body%20here","header":{"cc":"","sender":"ganith.perera@gmail.com","to":"dubTest@gmail.com","subject":"Test%20att%20files%20REST"}}
  7. --DQTy6UlmvkDsujh7Jv4_2AAvbb-wR9Ato
  8. Content-Disposition: form-data; name="attachments"; filename="leftmenubar_bg.jpg"
  9. Content-Type: application/octet-stream
  10. Content-Transfer-Encoding: binary
  11.  
  12. ÿØÿáExifII*ÿìDuckydÿá/http://ns.adobe.com/xap/1.0/<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>

 

Pega
April 16, 2018 - 11:29am
Response to GanithDNP

Did you set the values on the "pyAttachTypes" value list on pyRequestAttachmentPage?
This is how you set the content type for each part you are sending.

April 18, 2018 - 10:02am
Response to HOULJ

If we only use pyRequestAttachmentPage that is possible.

But in the current implementation JSON message is prepared using the connector rule. That is the issue we're facing where although we set a header in the connector rule its not getting override for the JSON part when request is prepared through pyInvokeRESTConnector activity. 

Pega
April 18, 2018 - 1:44pm
Response to GanithDNP

Okay, I think I see what you're running into.
I think I neglected to ask what version of Pega you are using. If you provide that, I should be able to give you some more detailed advice on overcoming this.

April 19, 2018 - 7:40am
Response to HOULJ

We're using Pega 7.2 version

December 28, 2018 - 6:16am

This issue is a bug in Pega 7.2 code base[SR-C25702]. This is fixed in 8.1 as per the SR update.

So we have removed message data from connector rule and add that JSON part into pyRequestAttachment page as the solution. In there we can provide the content type also as a parameter. And multi-part request also built in the expected format.