1

How do I get request form-data as a string in API Connect? I tried to get it in Gateway script by different ways, like apim.getvariable('request.body') or session.input.readAsBuffer, but everything was unsuccessful. I have two attachments in form-data and I would like to split it in my script.

At the moment I haven't found any documentation about processing form-data in IBM API Connect.

1 Answer 1

1

If you are using a POST QueryString you can decode the URI component in your Gateway script using:

var myQueryString = decodeURIComponent(apim.getvariable('request.body').item(0).toBuffer().toString())
3
  • Thank you for answer. I'm using POST request, but my data is located in formData, not in query string of URI. Here is description of my service: paths: /upload: post: parameters: - name: file in: formData description: File to upload required: false type: file Dec 21, 2017 at 8:50
  • 1
    Can you encode your Data as JSON then send it to API Connect? Dec 21, 2017 at 9:29
  • Thanks, I'll think about it. Dec 21, 2017 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.