How do you send a POST request using WizTools REST Client?
I'm trying to POST two values, that will be parsed by my PHP script, and echo a json-encoded response. These are two example values:
$_POST['function'] = "sampleTestFunction";
$_POST['username'] = "Dom";
I have the url endpoint definitely working (if I hard-code the values, the json-encoded response shows), but I can't seem to figure out how to post the values from WizTools.
Select POST in the Method tab, in the Body tab, select String Body from the drop-down, and click on Insert Parameter button (the last button next to the Content Type charset text box). You will be prompted for setting the Content-type to application/x-www-form-urlencoded. You could answer in affirmative to simulate HTML form post.
Essentially I had to go to the w3c specifications on a FORM element:
http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4
The enc-type (or encoding type) should be set to application/x-www-form-urlencoded when using the tool to simulate a standard, non-file form submission.
In the body part of the submission, the data should be similar to a GET submission, with key-values separated by an equal sign (=) and appended with an ampersand (&).
Example of the body-part:
name=domtancredi&rock=on
Here's an excerpt:
This is the default content type. Forms submitted with this content type must be encoded as follows:
Control names and values are escaped. Space characters are replaced by
+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by
%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e.,%0D%0A'). The control names/values are listed in the order they appear in the document. The name is separated from the value by
=' and name/value pairs are separated from each other by `&'.
In my case I was trying to send a JSON object to the REST service using POST.
In WizTools RESTClient I did the following:
In my case I had to set the AUTH to NTLM as well.
I've never used the client before, but I found a tutorial that might help you. First make sure that you authenticate the client properly, then follow part 2 of the tutorial regarding the post method. Just make sure you edit everything properly and remember to set the content-type to application/xml
and charset to UTF-8
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With