Forum Discussion

BHadfield's avatar
BHadfield
Contributor
7 years ago

url-encoded parameter for post body

Hi, 

 

I'm trying to make a rest request to an endpoint that requires a post query string but where the parameter value is a large XML document.

 

the body of the post would look like 

 

request=%3CValidation%3E%0A%3CInputs%... (very long string here)

 

I'm trying to accomplish a request that works like this curl call

curl -X POST --data-urlencode request@example.xml 'http://www.xxx.etc'

 

Other than sticking the XML into one of the parameter fields on the request (and then it is too long) how should this be done?

 

  • richie's avatar
    richie
    Community Hero

    Hi,

     

    erm - I 'think' this might help - but I'm unsure.

     

    Rather than post the query parameter within the URI you are submitting - you might be able to submit query parm within the body of the request.

     

    If you alter the MediaType from 'application/xml' (I'm guessing) to 'x-www-urlencoded' and then stick the query parms in the body of the request - I got this working about a week ago (never done it before) - it meant that I didn't have a really long query parm string in the URI.

     

    I 'think' if you need to keep your Content-Type header to 'application/xml' (so you can't change it to 'x-www-urlencoded') then I 'think' you can hit the 'Post QueryString' checkbox and copy the query parm in the body also.

     

    Hope this helps!

     

    richie

     

     

  • HackedBaked's avatar
    HackedBaked
    Occasional Visitor

    I ran into this same issue. For me I started a new REST request, then I didn't add any parameters. 
    I first selected "Post QueryString" this changed the Media type to "application/x-www-form-urlencoded", then I uncheckd the Post QueryString. 

    Now I can put in query statements directly in the body like this

    type=op&key=ourkey&cmd=<some><paloaltoxml><cmd></cmd></paloaltoxml></some>