Question

Send key-value pair requests to a service as multipart/form-data using connect-rest

I am trying to pass key-value pairs in the format of multipart/form-data as request to a service using connect-rest in post method as body,

So I have referred to few PDN articles on about how to pass request using connect-rest, Most scenarios were a file or string can be passed as multipart/form-data by setting the values in pyRequestAttachment page belonging to Data-ServiceMessage class and leaving the message body blank in post method of the connect-rest.

I tried to implement the same but unsure how to set key-value pairs in pyRequestAttachmentPage using a DataTranform or activity and I am unaware how the values are sent via connect-rest since i am not able to see the request in the connect-rest page in tracer.

Request to be sent: sample data = {"Username":"123456", "UserID":"testuser"}

I am setting in the below following format as of now in request Datatransform, also tried many combinations,

.pyAttachNames(1) = "Sample"

.pyAttachValues(1)="{\"Username\":\"123456\", \"UserID\":\"testuser\"}"

.pyAttachTypes(1)=application/json

So far i am not able to hit the service.

Please help me in setting correct format of request for key-value pairs and it should be in multipart/form-data.

Also, please provide any examples or samples if present.

***Edited by Moderator Marissa to update platform capability tags****

Comments

Keep up to date on this post and subscribe to comments

December 5, 2019 - 7:02am

We have the same problem, this curl works but we can't reproduce it in PEGA: 

  1. curl -X POST \
  2. http://theURL \
  3. -H 'Accept: /' \
  4. -H 'Accept-Encoding: gzip, deflate' \
  5. -H 'Cache-Control: no-cache' \
  6. -H 'Connection: keep-alive' \
  7. -H 'Content-Length: 41019' \
  8. -H 'Content-Type: multipart/form-data' \
  9. -H 'Host: master.staging.mortgages.ic.ing.net:8092' \
  10. -H 'Postman-Token: 49016524-fca0-4703-9292-8000fb3b9d81,d2077204-2d05-4e5d-bf22-9ce165e5ac91' \
  11. -H 'User-Agent: PostmanRuntime/7.18.0' \
  12. -H 'X-ING-AccessToken: Token' \
  13. -H 'X-ING-EGRESS-TARGET-SERVICE: DMS' \
  14. -H 'cache-control: no-cache' \
  15. -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  16. -F File=@/Users/ud17ir/Downloads/test.json

 

January 15, 2020 - 10:26pm

Hi,

Did you find any solution for this. How to pass the key value pair in JSON format.