Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you send a POST using WizTools Rest Client?

Tags:

rest

post

php

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.

like image 521
Dominic Tancredi Avatar asked Dec 20 '11 21:12

Dominic Tancredi


4 Answers

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.

like image 177
Subhash Chandran Avatar answered Nov 09 '22 07:11

Subhash Chandran


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 `&'.

like image 43
Dominic Tancredi Avatar answered Nov 09 '22 05:11

Dominic Tancredi


In my case I was trying to send a JSON object to the REST service using POST.

In WizTools RESTClient I did the following:

  1. Set -> POST in the fist tab
  2. In the BODY tab choose -> StringBody from the dropdown
  3. In the BODY tab edit ContentType & CharSet and set to -> Application/Json
  4. In the BODY tab I entered the JSON string: Example -> {"ParamOne":"value01","ParamTwo":"666"}

In my case I had to set the AUTH to NTLM as well.

like image 45
CIGNUM Avatar answered Nov 09 '22 07:11

CIGNUM


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.

  • Tutorial
like image 45
Runar Jørgensen Avatar answered Nov 09 '22 06:11

Runar Jørgensen