How to assert JSON that is present in a Multipart/form-data response

21 views Asked by At

We have a API, that returns the response in multipart/form-data content-type

(i.e) content-type = multipart/form-data;boundary=c7YW4wo4MTvgK-QvlRbnRe5FMPAkY-

Response is also having JSON values along with the multipart/form-data. Basically, the response has JSON and if any PDF associated with that data, it will also be coming in response as multipart/form-data. (PDF contents will be gibbrish)

So Currently, I'm doing a text based assertion in my karate regression suite like below.

And match response contains "ACTIVE"
And match response contains CustomerID

Is there a way to parse that JSON present in that multipart response and do the assertion that we do usually in karate. I'm trying to enhance the assertion part of that JSON.

Below is the image attached with the response, we will have PDF in a gibberish text after that JSON enter image description here

1

There are 1 answers

0
Peter Thomas On

This is honestly the first time I've heard of a response being of this mime-type, it is normally only for multipart-upload, so Karate does not support this currently.

We do handle this for mocks though, and there is some code in Karate that unpacks multipart content. It starts here --> link.

So my suggestion is that you contribute some code to Karate, or you just might be able to roll this into some helper Java class and do what you need to do.