1265 lines
36 KiB
Plaintext
1265 lines
36 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`generate request for C# RestSharp generate GET request 1`] = `
|
|
"var client = new RestClient(\\"https://httpbin.org\\");
|
|
|
|
var request = new RestRequest(\\"/path/to?a=b\\", DataFormat.Xml);
|
|
|
|
client.Authenticator = new HttpBasicAuthenticator(\\"mockUser\\", \\"mockPassword\\");
|
|
request.AddHeader(\\"h1\\", \\"h1v\\");
|
|
request.AddHeader(\\"h2\\", \\"h2v\\");
|
|
|
|
var response = client.Get(request);
|
|
|
|
if (!response.IsSuccessful)
|
|
{
|
|
Console.WriteLine(\\"An error occured \\" + response.ErrorMessage);
|
|
}
|
|
|
|
var result = response.Content;
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for C# RestSharp generate POST request for JSON 1`] = `
|
|
"var client = new RestClient(\\"https://httpbin.org\\");
|
|
|
|
var request = new RestRequest(\\"/path/to?a=b\\", DataFormat.Json);
|
|
|
|
request.AddHeader(\\"Authorization\\", \\"Bearer abcdefghijklmn\\");
|
|
request.AddHeader(\\"Content-Type\\", \\"application/json\\");
|
|
request.AddHeader(\\"h1\\", \\"h1v\\");
|
|
request.AddHeader(\\"h2\\", \\"h2v\\");
|
|
|
|
request.AddParameter(\\"text/json\\", @\\"{\\"\\"foo\\"\\": \\"\\"bar\\"\\", \\"\\"baz\\"\\": \\"\\"qux\\"\\"}\\", ParameterType.RequestBody);
|
|
|
|
var response = client.Post(request);
|
|
|
|
if (!response.IsSuccessful)
|
|
{
|
|
Console.WriteLine(\\"An error occured \\" + response.ErrorMessage);
|
|
}
|
|
|
|
var result = response.Content;
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for C# RestSharp generate POST request for XML 1`] = `
|
|
"var client = new RestClient(\\"https://httpbin.org\\");
|
|
|
|
var request = new RestRequest(\\"/path/to?a=b\\", DataFormat.Xml);
|
|
|
|
request.AddHeader(\\"Authorization\\", \\"Bearer abcdefghijklmn\\");
|
|
request.AddHeader(\\"Content-Type\\", \\"application/xml\\");
|
|
request.AddHeader(\\"h1\\", \\"h1v\\");
|
|
request.AddHeader(\\"h2\\", \\"h2v\\");
|
|
|
|
request.AddParameter(\\"text/xml\\", @\\"<?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"\\"bar\\"\\"></element>
|
|
</xml>\\", ParameterType.RequestBody);
|
|
|
|
var response = client.Post(request);
|
|
|
|
if (!response.IsSuccessful)
|
|
{
|
|
Console.WriteLine(\\"An error occured \\" + response.ErrorMessage);
|
|
}
|
|
|
|
var result = response.Content;
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for C# RestSharp generate PUT request for www-form-urlencoded 1`] = `
|
|
"var client = new RestClient(\\"https://httpbin.org\\");
|
|
|
|
var request = new RestRequest(\\"/path/to?a=b\\", DataFormat.Xml);
|
|
|
|
request.AddHeader(\\"Content-Type\\", \\"application/x-www-form-urlencoded\\");
|
|
|
|
request.AddParameter(\\"text/xml\\", @\\"foo=bar&baz=qux\\", ParameterType.RequestBody);
|
|
|
|
var response = client.Put(request);
|
|
|
|
if (!response.IsSuccessful)
|
|
{
|
|
Console.WriteLine(\\"An error occured \\" + response.ErrorMessage);
|
|
}
|
|
|
|
var result = response.Content;
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for Golang Native generate GET request 1`] = `
|
|
"req, err := http.NewRequest(\\"GET\\", \\"https://httpbin.org/path/to?a=b\\")
|
|
req.Header.Set(\\"Authorization\\", \\"Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk\\")
|
|
req.Header.Set(\\"h1\\", \\"h1v\\")
|
|
req.Header.Set(\\"h2\\", \\"h2v\\")
|
|
if err != nil {
|
|
log.Fatalf(\\"An Error Occured %v\\", err)
|
|
}
|
|
|
|
client := &http.Client{}
|
|
resp, err := client.Do(req)
|
|
if err != nil {
|
|
log.Fatalf(\\"An Error Occured %v\\", err)
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
body, err := ioutil.ReadAll(resp.Body)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for Golang Native generate POST request for JSON 1`] = `
|
|
"var reqBody = []byte(\`{\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}\`)
|
|
|
|
req, err := http.NewRequest(\\"POST\\", \\"https://httpbin.org/path/to?a=b\\", bytes.NewBuffer(reqBody))
|
|
req.Header.Set(\\"Content-Type\\", \\"application/json\\")
|
|
req.Header.Set(\\"Authorization\\", \\"Bearer abcdefghijklmn\\")
|
|
req.Header.Set(\\"h1\\", \\"h1v\\")
|
|
req.Header.Set(\\"h2\\", \\"h2v\\")
|
|
if err != nil {
|
|
log.Fatalf(\\"An Error Occured %v\\", err)
|
|
}
|
|
|
|
client := &http.Client{}
|
|
resp, err := client.Do(req)
|
|
if err != nil {
|
|
log.Fatalf(\\"An Error Occured %v\\", err)
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
body, err := ioutil.ReadAll(resp.Body)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for Golang Native generate POST request for XML 1`] = `
|
|
"req.Header.Set(\\"Content-Type\\", \\"application/xml\\")
|
|
req.Header.Set(\\"Authorization\\", \\"Bearer abcdefghijklmn\\")
|
|
req.Header.Set(\\"h1\\", \\"h1v\\")
|
|
req.Header.Set(\\"h2\\", \\"h2v\\")
|
|
if err != nil {
|
|
log.Fatalf(\\"An Error Occured %v\\", err)
|
|
}
|
|
|
|
client := &http.Client{}
|
|
resp, err := client.Do(req)
|
|
if err != nil {
|
|
log.Fatalf(\\"An Error Occured %v\\", err)
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
body, err := ioutil.ReadAll(resp.Body)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for Golang Native generate PUT request for www-form-urlencoded 1`] = `
|
|
"req, err := http.NewRequest(\\"PUT\\", \\"https://httpbin.org/path/to?a=b\\", strings.NewReader(\\"foo=bar&baz=qux\\"))
|
|
req.Header.Set(\\"Content-Type\\", \\"application/x-www-form-urlencoded\\")
|
|
if err != nil {
|
|
log.Fatalf(\\"An Error Occured %v\\", err)
|
|
}
|
|
|
|
client := &http.Client{}
|
|
resp, err := client.Do(req)
|
|
if err != nil {
|
|
log.Fatalf(\\"An Error Occured %v\\", err)
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
body, err := ioutil.ReadAll(resp.Body)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for Java OkHTTP Client generate GET request 1`] = `
|
|
"OkHttpClient client = new OkHttpClient().newBuilder().build();
|
|
Request request = new Request.Builder()
|
|
.url(\\"https://httpbin.org/path/to?a=b\\")
|
|
.method(\\"GET\\", null)
|
|
.addHeader(\\"authorization\\", \\"Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk\\")
|
|
|
|
.addHeader(\\"h1\\", \\"h1v\\")
|
|
.addHeader(\\"h2\\", \\"h2v\\")
|
|
.build();
|
|
Response response = client.newCall(request).execute();"
|
|
`;
|
|
|
|
exports[`generate request for Java OkHTTP Client generate POST request for JSON 1`] = `
|
|
"OkHttpClient client = new OkHttpClient().newBuilder().build();
|
|
MediaType mediaType = MediaType.parse(\\"application/json\\");
|
|
RequestBody body = RequestBody.create(mediaType,\\"{\\\\\\"foo\\\\\\": \\\\\\"bar\\\\\\", \\\\\\"baz\\\\\\": \\\\\\"qux\\\\\\"}\\");
|
|
Request request = new Request.Builder()
|
|
.url(\\"https://httpbin.org/path/to?a=b\\")
|
|
.method(\\"POST\\", body)
|
|
.addHeader(\\"authorization\\", \\"Bearer abcdefghijklmn\\" )
|
|
|
|
.addHeader(\\"h1\\", \\"h1v\\")
|
|
.addHeader(\\"h2\\", \\"h2v\\")
|
|
.build();
|
|
Response response = client.newCall(request).execute();"
|
|
`;
|
|
|
|
exports[`generate request for Java OkHTTP Client generate POST request for XML 1`] = `
|
|
"OkHttpClient client = new OkHttpClient().newBuilder().build();
|
|
MediaType mediaType = MediaType.parse(\\"application/xml\\");
|
|
RequestBody body = RequestBody.create(mediaType,\\"<?xml version='1.0' encoding='utf-8'?>\\\\n<xml>\\\\n <element foo=\\\\\\"bar\\\\\\"></element>\\\\n</xml>\\");
|
|
Request request = new Request.Builder()
|
|
.url(\\"https://httpbin.org/path/to?a=b\\")
|
|
.method(\\"POST\\", body)
|
|
.addHeader(\\"authorization\\", \\"Bearer abcdefghijklmn\\" )
|
|
|
|
.addHeader(\\"h1\\", \\"h1v\\")
|
|
.addHeader(\\"h2\\", \\"h2v\\")
|
|
.build();
|
|
Response response = client.newCall(request).execute();"
|
|
`;
|
|
|
|
exports[`generate request for Java OkHTTP Client generate PUT request for www-form-urlencoded 1`] = `
|
|
"OkHttpClient client = new OkHttpClient().newBuilder().build();
|
|
MediaType mediaType = MediaType.parse(\\"application/x-www-form-urlencoded\\");
|
|
RequestBody body = RequestBody.create(mediaType,\\"foo=bar&baz=qux\\");
|
|
Request request = new Request.Builder()
|
|
.url(\\"https://httpbin.org/path/to?a=b\\")
|
|
.method(\\"PUT\\", body)
|
|
.build();
|
|
Response response = client.newCall(request).execute();"
|
|
`;
|
|
|
|
exports[`generate request for Java Unirest generate GET request 1`] = `
|
|
"HttpResponse<String> response = Unirest.get(\\"https://httpbin.org/path/to?a=b\\")
|
|
.header(\\"authorization\\", \\"Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk\\")
|
|
.header(\\"h1\\", \\"h1v\\")
|
|
.header(\\"h2\\", \\"h2v\\")
|
|
|
|
.asString();
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for Java Unirest generate POST request for JSON 1`] = `
|
|
"HttpResponse<String> response = Unirest.post(\\"https://httpbin.org/path/to?a=b\\")
|
|
.header(\\"authorization\\", \\"Bearer abcdefghijklmn\\")
|
|
.header(\\"h1\\", \\"h1v\\")
|
|
.header(\\"h2\\", \\"h2v\\")
|
|
.header(\\"Content-Type\\", \\"application/json\\")
|
|
.body(\\"{\\\\\\"foo\\\\\\": \\\\\\"bar\\\\\\", \\\\\\"baz\\\\\\": \\\\\\"qux\\\\\\"}\\")
|
|
.asString();
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for Java Unirest generate POST request for XML 1`] = `
|
|
"HttpResponse<String> response = Unirest.post(\\"https://httpbin.org/path/to?a=b\\")
|
|
.header(\\"authorization\\", \\"Bearer abcdefghijklmn\\")
|
|
.header(\\"h1\\", \\"h1v\\")
|
|
.header(\\"h2\\", \\"h2v\\")
|
|
.header(\\"Content-Type\\", \\"application/xml\\")
|
|
.body(\\"<?xml version='1.0' encoding='utf-8'?>\\\\n<xml>\\\\n <element foo=\\\\\\"bar\\\\\\"></element>\\\\n</xml>\\")
|
|
.asString();
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for Java Unirest generate PUT request for www-form-urlencoded 1`] = `
|
|
"HttpResponse<String> response = Unirest.put(\\"https://httpbin.org/path/to?a=b\\")
|
|
.header(\\"Content-Type\\", \\"application/x-www-form-urlencoded\\")
|
|
.body(\\"foo=bar&baz=qux\\")
|
|
.asString();
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript Axios generate GET request 1`] = `
|
|
"axios.get('https://httpbin.org/path/to?a=b',{
|
|
headers : { \\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\",
|
|
\\"Authorization\\": \\"Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk\\"}
|
|
}.then(response => {
|
|
console.log(response);
|
|
}).catch(error => {
|
|
console.log(error);
|
|
})
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript Axios generate POST request for JSON 1`] = `
|
|
"axios.post('https://httpbin.org/path/to?a=b',{
|
|
headers : { \\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\",
|
|
\\"Content-Type\\": \\"application/json; charset=utf-8\\",
|
|
\\"Authorization\\": \\"Bearer abcdefghijklmn\\"}
|
|
}.then(response => {
|
|
console.log(response);
|
|
}).catch(error => {
|
|
console.log(error);
|
|
})
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript Axios generate POST request for XML 1`] = `
|
|
"axios.post('https://httpbin.org/path/to?a=b',{
|
|
headers : { \\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\",
|
|
\\"Content-Type\\": \\"application/xml; charset=utf-8\\",
|
|
\\"Authorization\\": \\"Bearer abcdefghijklmn\\"}
|
|
}.then(response => {
|
|
console.log(response);
|
|
}).catch(error => {
|
|
console.log(error);
|
|
})
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript Axios generate PUT request for www-form-urlencoded 1`] = `
|
|
"axios.put('https://httpbin.org/path/to?a=b', foo=bar&baz=qux,{
|
|
headers : {\\"Content-Type\\": \\"application/x-www-form-urlencoded; charset=utf-8\\"}
|
|
}.then(response => {
|
|
console.log(response);
|
|
}).catch(error => {
|
|
console.log(error);
|
|
})
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript Fetch generate GET request 1`] = `
|
|
"fetch(\\"https://httpbin.org/path/to?a=b\\", {
|
|
method: \\"GET\\",
|
|
headers: {
|
|
\\"Authorization\\": \\"Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk\\",
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\"
|
|
},
|
|
credentials: \\"same-origin\\"
|
|
}).then(function(response) {
|
|
response.status
|
|
response.statusText
|
|
response.headers
|
|
response.url
|
|
|
|
return response.text()
|
|
}).catch(function(error) {
|
|
error.message
|
|
})"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript Fetch generate POST request for JSON 1`] = `
|
|
"fetch(\\"https://httpbin.org/path/to?a=b\\", {
|
|
method: \\"POST\\",
|
|
body: JSON.stringify({\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}),
|
|
headers: {
|
|
\\"Authorization\\": \\"Bearer abcdefghijklmn\\",
|
|
\\"Content-Type\\": \\"application/json; charset=utf-8\\",
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\"
|
|
},
|
|
credentials: \\"same-origin\\"
|
|
}).then(function(response) {
|
|
response.status
|
|
response.statusText
|
|
response.headers
|
|
response.url
|
|
|
|
return response.text()
|
|
}).catch(function(error) {
|
|
error.message
|
|
})"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript Fetch generate POST request for XML 1`] = `
|
|
"fetch(\\"https://httpbin.org/path/to?a=b\\", {
|
|
method: \\"POST\\",
|
|
body: <?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>,
|
|
headers: {
|
|
\\"Authorization\\": \\"Bearer abcdefghijklmn\\",
|
|
\\"Content-Type\\": \\"application/xml; charset=utf-8\\",
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\"
|
|
},
|
|
credentials: \\"same-origin\\"
|
|
}).then(function(response) {
|
|
response.status
|
|
response.statusText
|
|
response.headers
|
|
response.url
|
|
|
|
return response.text()
|
|
}).catch(function(error) {
|
|
error.message
|
|
})"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript Fetch generate PUT request for www-form-urlencoded 1`] = `
|
|
"fetch(\\"https://httpbin.org/path/to?a=b\\", {
|
|
method: \\"PUT\\",
|
|
body: \\"foo=bar&baz=qux\\",
|
|
headers: {
|
|
\\"Content-Type\\": \\"application/x-www-form-urlencoded; charset=utf-8\\"
|
|
},
|
|
credentials: \\"same-origin\\"
|
|
}).then(function(response) {
|
|
response.status
|
|
response.statusText
|
|
response.headers
|
|
response.url
|
|
|
|
return response.text()
|
|
}).catch(function(error) {
|
|
error.message
|
|
})"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript XHR generate GET request 1`] = `
|
|
"const xhr = new XMLHttpRequest()
|
|
xhr.open('GET', 'https://httpbin.org/path/to?a=b', true, 'mockUser', 'mockPassword')
|
|
xhr.setRequestHeader('h1', 'h1v')
|
|
xhr.setRequestHeader('h2', 'h2v')
|
|
xhr.send()"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript XHR generate POST request for JSON 1`] = `
|
|
"const xhr = new XMLHttpRequest()
|
|
xhr.open('POST', 'https://httpbin.org/path/to?a=b', true, null, null)
|
|
xhr.setRequestHeader('Authorization', 'Bearer abcdefghijklmn')
|
|
xhr.setRequestHeader('h1', 'h1v')
|
|
xhr.setRequestHeader('h2', 'h2v')
|
|
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8')
|
|
xhr.send(JSON.stringify({\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}))"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript XHR generate POST request for XML 1`] = `
|
|
"const xhr = new XMLHttpRequest()
|
|
xhr.open('POST', 'https://httpbin.org/path/to?a=b', true, null, null)
|
|
xhr.setRequestHeader('Authorization', 'Bearer abcdefghijklmn')
|
|
xhr.setRequestHeader('h1', 'h1v')
|
|
xhr.setRequestHeader('h2', 'h2v')
|
|
xhr.setRequestHeader('Content-Type', 'application/xml; charset=utf-8')
|
|
xhr.send(<?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>)"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript XHR generate PUT request for www-form-urlencoded 1`] = `
|
|
"const xhr = new XMLHttpRequest()
|
|
xhr.open('PUT', 'https://httpbin.org/path/to?a=b', true, null, null)
|
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8')
|
|
xhr.send(\\"foo=bar&baz=qux\\")"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript jQuery generate GET request 1`] = `
|
|
"jQuery.ajax({
|
|
url: \\"https://httpbin.org/path/to?a=b\\",
|
|
method: \\"GET\\",
|
|
headers: {
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\",
|
|
\\"Authorization\\": \\"Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk\\"
|
|
}
|
|
}).then(response => {
|
|
console.log(response);
|
|
}).catch(error => {
|
|
console.log(error);
|
|
})
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript jQuery generate POST request for JSON 1`] = `
|
|
"jQuery.ajax({
|
|
url: \\"https://httpbin.org/path/to?a=b\\",
|
|
method: \\"POST\\",
|
|
body: {\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"},
|
|
contentType: \\"application/json; charset=utf-8\\",
|
|
headers: {
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\",
|
|
\\"Content-Type\\": \\"application/json; charset=utf-8\\",
|
|
\\"Authorization\\": \\"Bearer abcdefghijklmn\\"
|
|
}
|
|
}).then(response => {
|
|
console.log(response);
|
|
}).catch(error => {
|
|
console.log(error);
|
|
})
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript jQuery generate POST request for XML 1`] = `
|
|
"jQuery.ajax({
|
|
url: \\"https://httpbin.org/path/to?a=b\\",
|
|
method: \\"POST\\",
|
|
body: <?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>,
|
|
contentType: \\"application/xml; charset=utf-8\\",
|
|
headers: {
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\",
|
|
\\"Content-Type\\": \\"application/xml; charset=utf-8\\",
|
|
\\"Authorization\\": \\"Bearer abcdefghijklmn\\"
|
|
}
|
|
}).then(response => {
|
|
console.log(response);
|
|
}).catch(error => {
|
|
console.log(error);
|
|
})
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for JavaScript jQuery generate PUT request for www-form-urlencoded 1`] = `
|
|
"jQuery.ajax({
|
|
url: \\"https://httpbin.org/path/to?a=b\\",
|
|
method: \\"PUT\\",
|
|
body: foo=bar&baz=qux,
|
|
contentType: \\"application/x-www-form-urlencoded; charset=utf-8\\",
|
|
headers: {
|
|
\\"Content-Type\\": \\"application/x-www-form-urlencoded; charset=utf-8\\"
|
|
}
|
|
}).then(response => {
|
|
console.log(response);
|
|
}).catch(error => {
|
|
console.log(error);
|
|
})
|
|
"
|
|
`;
|
|
|
|
exports[`generate request for NodeJs Native generate GET request 1`] = `
|
|
"const http = require('http');
|
|
|
|
const url = 'https://httpbin.org/path/to?a=b';
|
|
const options = {
|
|
method: 'GET',
|
|
headers: {
|
|
\\"Authorization\\": \\"Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk\\",
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\"
|
|
}};
|
|
|
|
const request = http.request(url, options, (response) => {
|
|
console.log(response);
|
|
});
|
|
|
|
request.on('error', (e) => {
|
|
console.error(e);
|
|
});
|
|
request.end();"
|
|
`;
|
|
|
|
exports[`generate request for NodeJs Native generate POST request for JSON 1`] = `
|
|
"const http = require('http');
|
|
|
|
const url = 'https://httpbin.org/path/to?a=b';
|
|
const options = {
|
|
method: 'POST',
|
|
headers: {
|
|
\\"Authorization\\": \\"Bearer abcdefghijklmn\\",
|
|
\\"Content-Type\\": \\"application/json; charset=utf-8\\",
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\"
|
|
}};
|
|
|
|
const request = http.request(url, options, (response) => {
|
|
console.log(response);
|
|
});
|
|
|
|
request.on('error', (e) => {
|
|
console.error(e);
|
|
});
|
|
|
|
request.write(JSON.stringify({\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}));
|
|
request.end();"
|
|
`;
|
|
|
|
exports[`generate request for NodeJs Native generate POST request for XML 1`] = `
|
|
"const http = require('http');
|
|
|
|
const url = 'https://httpbin.org/path/to?a=b';
|
|
const options = {
|
|
method: 'POST',
|
|
headers: {
|
|
\\"Authorization\\": \\"Bearer abcdefghijklmn\\",
|
|
\\"Content-Type\\": \\"application/xml; charset=utf-8\\",
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\"
|
|
}};
|
|
|
|
const request = http.request(url, options, (response) => {
|
|
console.log(response);
|
|
});
|
|
|
|
request.on('error', (e) => {
|
|
console.error(e);
|
|
});
|
|
|
|
request.write(\`<?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>\`);
|
|
request.end();"
|
|
`;
|
|
|
|
exports[`generate request for NodeJs Native generate PUT request for www-form-urlencoded 1`] = `
|
|
"const http = require('http');
|
|
|
|
const url = 'https://httpbin.org/path/to?a=b';
|
|
const options = {
|
|
method: 'PUT',
|
|
headers: {
|
|
\\"Content-Type\\": \\"application/x-www-form-urlencoded; charset=utf-8\\"
|
|
}};
|
|
|
|
const request = http.request(url, options, (response) => {
|
|
console.log(response);
|
|
});
|
|
|
|
request.on('error', (e) => {
|
|
console.error(e);
|
|
});
|
|
|
|
request.write(\`foo=bar&baz=qux\`);
|
|
request.end();"
|
|
`;
|
|
|
|
exports[`generate request for NodeJs Request generate GET request 1`] = `
|
|
"const request = require('request');
|
|
const options = {
|
|
method: 'get',
|
|
url: 'https://httpbin.org/path/to?a=b',
|
|
headers: {
|
|
\\"Authorization\\": \\"Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk\\",
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\"
|
|
}
|
|
}
|
|
request(options, (error, response) => {
|
|
if (error) throw new Error(error);
|
|
console.log(response.body);
|
|
});"
|
|
`;
|
|
|
|
exports[`generate request for NodeJs Request generate POST request for JSON 1`] = `
|
|
"const request = require('request');
|
|
const options = {
|
|
method: 'post',
|
|
url: 'https://httpbin.org/path/to?a=b',
|
|
body: JSON.stringify({\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}),
|
|
headers: {
|
|
\\"Authorization\\": \\"Bearer abcdefghijklmn\\",
|
|
\\"Content-Type\\": \\"application/json; charset=utf-8\\",
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\"
|
|
}
|
|
}
|
|
request(options, (error, response) => {
|
|
if (error) throw new Error(error);
|
|
console.log(response.body);
|
|
});"
|
|
`;
|
|
|
|
exports[`generate request for NodeJs Request generate POST request for XML 1`] = `
|
|
"const request = require('request');
|
|
const options = {
|
|
method: 'post',
|
|
url: 'https://httpbin.org/path/to?a=b',
|
|
body: \`<?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>\`,
|
|
headers: {
|
|
\\"Authorization\\": \\"Bearer abcdefghijklmn\\",
|
|
\\"Content-Type\\": \\"application/xml; charset=utf-8\\",
|
|
\\"h1\\": \\"h1v\\",
|
|
\\"h2\\": \\"h2v\\"
|
|
}
|
|
}
|
|
request(options, (error, response) => {
|
|
if (error) throw new Error(error);
|
|
console.log(response.body);
|
|
});"
|
|
`;
|
|
|
|
exports[`generate request for NodeJs Request generate PUT request for www-form-urlencoded 1`] = `
|
|
"const request = require('request');
|
|
const options = {
|
|
method: 'put',
|
|
url: 'https://httpbin.org/path/to?a=b',
|
|
form: {\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"},
|
|
headers: {
|
|
\\"Content-Type\\": \\"application/x-www-form-urlencoded; charset=utf-8\\"
|
|
}
|
|
}
|
|
request(options, (error, response) => {
|
|
if (error) throw new Error(error);
|
|
console.log(response.body);
|
|
});"
|
|
`;
|
|
|
|
exports[`generate request for PHP cURL generate GET request 1`] = `
|
|
<?php
|
|
$curl = curl_init();
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => "https://httpbin.org/path/to?a=b",
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => "",
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => "GET",
|
|
CURLOPT_HTTPHEADER => array(
|
|
"Authorization: Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk",
|
|
"h1: h1v",
|
|
"h2: h2v"
|
|
)
|
|
));
|
|
$response = curl_exec($curl);
|
|
curl_close($curl);
|
|
echo $response;
|
|
`;
|
|
|
|
exports[`generate request for PHP cURL generate POST request for JSON 1`] = `
|
|
<?php
|
|
$curl = curl_init();
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => "https://httpbin.org/path/to?a=b",
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => "",
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => "POST",
|
|
CURLOPT_POSTFIELDS => "{\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}",
|
|
CURLOPT_HTTPHEADER => array(
|
|
"Authorization: Bearer abcdefghijklmn",
|
|
"Content-Type: application/json; charset=utf-8",
|
|
"h1: h1v",
|
|
"h2: h2v"
|
|
)
|
|
));
|
|
$response = curl_exec($curl);
|
|
curl_close($curl);
|
|
echo $response;
|
|
`;
|
|
|
|
exports[`generate request for PHP cURL generate POST request for XML 1`] = `
|
|
<?php
|
|
$curl = curl_init();
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => "https://httpbin.org/path/to?a=b",
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => "",
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => "POST",
|
|
CURLOPT_POSTFIELDS => array(<?xmlversion='1.0'encoding='utf-8'?><xml>
|
|
<elementfoo="bar">
|
|
</element>
|
|
</xml>),
|
|
CURLOPT_HTTPHEADER => array(
|
|
"Authorization: Bearer abcdefghijklmn",
|
|
"Content-Type: application/xml; charset=utf-8",
|
|
"h1: h1v",
|
|
"h2: h2v"
|
|
)
|
|
));
|
|
$response = curl_exec($curl);
|
|
curl_close($curl);
|
|
echo $response;
|
|
`;
|
|
|
|
exports[`generate request for PHP cURL generate PUT request for www-form-urlencoded 1`] = `
|
|
<?php
|
|
$curl = curl_init();
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => "https://httpbin.org/path/to?a=b",
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => "",
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => "PUT",
|
|
CURLOPT_POSTFIELDS => "foo=bar&baz=qux",
|
|
CURLOPT_HTTPHEADER => array(
|
|
"Content-Type: application/x-www-form-urlencoded; charset=utf-8"
|
|
)
|
|
));
|
|
$response = curl_exec($curl);
|
|
curl_close($curl);
|
|
echo $response;
|
|
`;
|
|
|
|
exports[`generate request for Powershell RestMethod generate GET request 1`] = `
|
|
"$headers = @{
|
|
'h1' = 'h1v'
|
|
'h2' = 'h2v'
|
|
'Authorization' = 'Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk'
|
|
}
|
|
|
|
Invoke-RestMethod -Method 'Get' -Uri 'https://httpbin.org/path/to?a=b' -Headers $headers"
|
|
`;
|
|
|
|
exports[`generate request for Powershell RestMethod generate POST request for JSON 1`] = `
|
|
"$body = @'
|
|
{\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}
|
|
'@
|
|
|
|
$headers = @{
|
|
'h1' = 'h1v'
|
|
'h2' = 'h2v'
|
|
'Content-Type' = 'application/json; charset=utf-8'
|
|
'Authorization' = 'Bearer abcdefghijklmn'
|
|
}
|
|
|
|
Invoke-RestMethod -Method 'Post' -Uri 'https://httpbin.org/path/to?a=b' -ContentType 'application/json; charset=utf-8' -Headers $headers -Body $body"
|
|
`;
|
|
|
|
exports[`generate request for Powershell RestMethod generate POST request for XML 1`] = `
|
|
"$body = @'
|
|
<?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>
|
|
'@
|
|
|
|
$headers = @{
|
|
'h1' = 'h1v'
|
|
'h2' = 'h2v'
|
|
'Content-Type' = 'application/xml; charset=utf-8'
|
|
'Authorization' = 'Bearer abcdefghijklmn'
|
|
}
|
|
|
|
Invoke-RestMethod -Method 'Post' -Uri 'https://httpbin.org/path/to?a=b' -ContentType 'application/xml; charset=utf-8' -Headers $headers -Body $body"
|
|
`;
|
|
|
|
exports[`generate request for Powershell RestMethod generate PUT request for www-form-urlencoded 1`] = `
|
|
"$body = @'
|
|
foo=bar&baz=qux
|
|
'@
|
|
|
|
$headers = @{
|
|
'Content-Type' = 'application/x-www-form-urlencoded; charset=utf-8'
|
|
}
|
|
|
|
Invoke-RestMethod -Method 'Put' -Uri 'https://httpbin.org/path/to?a=b' -ContentType 'application/x-www-form-urlencoded; charset=utf-8' -Headers $headers -Body $body"
|
|
`;
|
|
|
|
exports[`generate request for Python HTTP Client generate GET request 1`] = `
|
|
"import http.client
|
|
import mimetypes
|
|
conn = http.client.HTTPSConnection(\\"httpbin.org\\")
|
|
headers = {
|
|
'Authorization': 'Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk',
|
|
'h1': 'h1v',
|
|
'h2': 'h2v'
|
|
}
|
|
payload = ''
|
|
conn.request(\\"GET\\", \\"/path/to?a=b\\", payload, headers)
|
|
res = conn.getresponse()
|
|
data = res.read()
|
|
print(data.decode(\\"utf-8\\"))"
|
|
`;
|
|
|
|
exports[`generate request for Python HTTP Client generate POST request for JSON 1`] = `
|
|
"import http.client
|
|
import mimetypes
|
|
conn = http.client.HTTPSConnection(\\"httpbin.org\\")
|
|
headers = {
|
|
'Authorization': 'Bearer abcdefghijklmn',
|
|
'h1': 'h1v',
|
|
'h2': 'h2v',
|
|
'Content-Type': 'application/json'
|
|
}
|
|
payload = \\"{\\\\\\"foo\\\\\\": \\\\\\"bar\\\\\\", \\\\\\"baz\\\\\\": \\\\\\"qux\\\\\\"}\\"
|
|
conn.request(\\"POST\\", \\"/path/to?a=b\\", payload, headers)
|
|
res = conn.getresponse()
|
|
data = res.read()
|
|
print(data.decode(\\"utf-8\\"))"
|
|
`;
|
|
|
|
exports[`generate request for Python HTTP Client generate POST request for XML 1`] = `
|
|
"import http.client
|
|
import mimetypes
|
|
conn = http.client.HTTPSConnection(\\"httpbin.org\\")
|
|
headers = {
|
|
'Authorization': 'Bearer abcdefghijklmn',
|
|
'h1': 'h1v',
|
|
'h2': 'h2v',
|
|
'Content-Type': 'application/xml'
|
|
}
|
|
paylod = '''<?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>'''
|
|
conn.request(\\"POST\\", \\"/path/to?a=b\\", payload, headers)
|
|
res = conn.getresponse()
|
|
data = res.read()
|
|
print(data.decode(\\"utf-8\\"))"
|
|
`;
|
|
|
|
exports[`generate request for Python HTTP Client generate PUT request for www-form-urlencoded 1`] = `
|
|
"import http.client
|
|
import mimetypes
|
|
conn = http.client.HTTPSConnection(\\"httpbin.org\\")
|
|
headers = {
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
}
|
|
payload = [('foo', 'bar'),
|
|
('baz', 'qux')]
|
|
conn.request(\\"PUT\\", \\"/path/to?a=b\\", payload, headers)
|
|
res = conn.getresponse()
|
|
data = res.read()
|
|
print(data.decode(\\"utf-8\\"))"
|
|
`;
|
|
|
|
exports[`generate request for Python Requests generate GET request 1`] = `
|
|
"import requests
|
|
|
|
url = 'https://httpbin.org/path/to?a=b'
|
|
headers = {
|
|
'Authorization': 'Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk',
|
|
'h1': 'h1v',
|
|
'h2': 'h2v'
|
|
}
|
|
response = requests.request(
|
|
'GET',
|
|
'https://httpbin.org/path/to?a=b',
|
|
headers=headers,
|
|
)
|
|
|
|
print(response)"
|
|
`;
|
|
|
|
exports[`generate request for Python Requests generate POST request for JSON 1`] = `
|
|
"import requests
|
|
|
|
url = 'https://httpbin.org/path/to?a=b'
|
|
headers = {
|
|
'Authorization': 'Bearer abcdefghijklmn',
|
|
'h1': 'h1v',
|
|
'h2': 'h2v',
|
|
'Content-Type': 'application/json'
|
|
}
|
|
data = \\"{\\\\\\"foo\\\\\\": \\\\\\"bar\\\\\\", \\\\\\"baz\\\\\\": \\\\\\"qux\\\\\\"}\\"
|
|
response = requests.request(
|
|
'POST',
|
|
'https://httpbin.org/path/to?a=b',
|
|
data=data,
|
|
headers=headers,
|
|
)
|
|
|
|
print(response)"
|
|
`;
|
|
|
|
exports[`generate request for Python Requests generate POST request for XML 1`] = `
|
|
"import requests
|
|
|
|
url = 'https://httpbin.org/path/to?a=b'
|
|
headers = {
|
|
'Authorization': 'Bearer abcdefghijklmn',
|
|
'h1': 'h1v',
|
|
'h2': 'h2v',
|
|
'Content-Type': 'application/xml'
|
|
}
|
|
data = '''<?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>'''
|
|
response = requests.request(
|
|
'POST',
|
|
'https://httpbin.org/path/to?a=b',
|
|
data=data,
|
|
headers=headers,
|
|
)
|
|
|
|
print(response)"
|
|
`;
|
|
|
|
exports[`generate request for Python Requests generate PUT request for www-form-urlencoded 1`] = `
|
|
"import requests
|
|
|
|
url = 'https://httpbin.org/path/to?a=b'
|
|
headers = {
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
}
|
|
data = [('foo', 'bar'),
|
|
('baz', 'qux')]
|
|
response = requests.request(
|
|
'PUT',
|
|
'https://httpbin.org/path/to?a=b',
|
|
data=data,
|
|
headers=headers,
|
|
)
|
|
|
|
print(response)"
|
|
`;
|
|
|
|
exports[`generate request for Ruby Net::HTTP generate GET request 1`] = `
|
|
"require 'net/http'
|
|
|
|
uri = URI.parse('https://httpbin.org/path/to?a=b')
|
|
|
|
request = Net::HTTP::Get.new(uri)
|
|
request['h1'] = 'h1v'
|
|
request['h2'] = 'h2v'
|
|
request.basic_auth('mockUser', 'mockPassword')
|
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
http.use_ssl = uri.is_a?(URI::HTTPS)
|
|
response = http.request(request)
|
|
|
|
unless response.is_a?(Net::HTTPSuccess) then
|
|
raise \\"An error occurred: #{response.code} #{response.message}\\"
|
|
else
|
|
puts response.body
|
|
end"
|
|
`;
|
|
|
|
exports[`generate request for Ruby Net::HTTP generate POST request for JSON 1`] = `
|
|
"require 'net/http'
|
|
|
|
uri = URI.parse('https://httpbin.org/path/to?a=b')
|
|
|
|
request = Net::HTTP::Post.new(uri)
|
|
request['Content-Type'] = 'application/json'
|
|
request['h1'] = 'h1v'
|
|
request['h2'] = 'h2v'
|
|
request['Authorization'] = 'Bearer abcdefghijklmn'
|
|
request.body = '{\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}'
|
|
|
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
http.use_ssl = uri.is_a?(URI::HTTPS)
|
|
response = http.request(request)
|
|
|
|
unless response.is_a?(Net::HTTPSuccess) then
|
|
raise \\"An error occurred: #{response.code} #{response.message}\\"
|
|
else
|
|
puts response.body
|
|
end"
|
|
`;
|
|
|
|
exports[`generate request for Ruby Net::HTTP generate POST request for XML 1`] = `
|
|
"require 'net/http'
|
|
|
|
uri = URI.parse('https://httpbin.org/path/to?a=b')
|
|
|
|
request = Net::HTTP::Post.new(uri)
|
|
request['Content-Type'] = 'application/xml'
|
|
request['h1'] = 'h1v'
|
|
request['h2'] = 'h2v'
|
|
request['Authorization'] = 'Bearer abcdefghijklmn'
|
|
request.body = '<?xml version=\\\\'1.0\\\\' encoding=\\\\'utf-8\\\\'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>'
|
|
|
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
http.use_ssl = uri.is_a?(URI::HTTPS)
|
|
response = http.request(request)
|
|
|
|
unless response.is_a?(Net::HTTPSuccess) then
|
|
raise \\"An error occurred: #{response.code} #{response.message}\\"
|
|
else
|
|
puts response.body
|
|
end"
|
|
`;
|
|
|
|
exports[`generate request for Ruby Net::HTTP generate PUT request for www-form-urlencoded 1`] = `
|
|
"require 'net/http'
|
|
|
|
uri = URI.parse('https://httpbin.org/path/to?a=b')
|
|
|
|
request = Net::HTTP::Put.new(uri)
|
|
request['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
request.body = 'foo=bar&baz=qux'
|
|
|
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
http.use_ssl = uri.is_a?(URI::HTTPS)
|
|
response = http.request(request)
|
|
|
|
unless response.is_a?(Net::HTTPSuccess) then
|
|
raise \\"An error occurred: #{response.code} #{response.message}\\"
|
|
else
|
|
puts response.body
|
|
end"
|
|
`;
|
|
|
|
exports[`generate request for Salesforce Apex generate GET request 1`] = `
|
|
"HttpRequest request = new HttpRequest();
|
|
request.setMethod('GET');
|
|
request.setEndpoint('https://httpbin.org/path/to?a=b');
|
|
|
|
request.setHeader('Authorization', 'Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk');
|
|
request.setHeader('h1', 'h1v');
|
|
request.setHeader('h2', 'h2v');
|
|
|
|
try {
|
|
Http client = new Http();
|
|
HttpResponse response = client.send(request);
|
|
System.debug(response.getBody());
|
|
} catch (CalloutException ex) {
|
|
System.debug('An error occured ' + ex.getMessage());
|
|
}"
|
|
`;
|
|
|
|
exports[`generate request for Salesforce Apex generate POST request for JSON 1`] = `
|
|
"HttpRequest request = new HttpRequest();
|
|
request.setMethod('POST');
|
|
request.setEndpoint('https://httpbin.org/path/to?a=b');
|
|
|
|
request.setHeader('Authorization', 'Bearer abcdefghijklmn');
|
|
request.setHeader('Content-Type', 'application/json');
|
|
request.setHeader('h1', 'h1v');
|
|
request.setHeader('h2', 'h2v');
|
|
|
|
request.setBody('{\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}');
|
|
|
|
try {
|
|
Http client = new Http();
|
|
HttpResponse response = client.send(request);
|
|
System.debug(response.getBody());
|
|
} catch (CalloutException ex) {
|
|
System.debug('An error occured ' + ex.getMessage());
|
|
}"
|
|
`;
|
|
|
|
exports[`generate request for Salesforce Apex generate POST request for XML 1`] = `
|
|
"HttpRequest request = new HttpRequest();
|
|
request.setMethod('POST');
|
|
request.setEndpoint('https://httpbin.org/path/to?a=b');
|
|
|
|
request.setHeader('Authorization', 'Bearer abcdefghijklmn');
|
|
request.setHeader('Content-Type', 'application/xml');
|
|
request.setHeader('h1', 'h1v');
|
|
request.setHeader('h2', 'h2v');
|
|
|
|
request.setBody('<?xml version=\\\\'1.0\\\\' encoding=\\\\'utf-8\\\\'?>\\\\n<xml>\\\\n <element foo=\\"bar\\"></element>\\\\n</xml>');
|
|
|
|
try {
|
|
Http client = new Http();
|
|
HttpResponse response = client.send(request);
|
|
System.debug(response.getBody());
|
|
} catch (CalloutException ex) {
|
|
System.debug('An error occured ' + ex.getMessage());
|
|
}"
|
|
`;
|
|
|
|
exports[`generate request for Salesforce Apex generate PUT request for www-form-urlencoded 1`] = `
|
|
"HttpRequest request = new HttpRequest();
|
|
request.setMethod('PUT');
|
|
request.setEndpoint('https://httpbin.org/path/to?a=b');
|
|
|
|
request.setHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
|
|
request.setBody('foo=bar&baz=qux');
|
|
|
|
try {
|
|
Http client = new Http();
|
|
HttpResponse response = client.send(request);
|
|
System.debug(response.getBody());
|
|
} catch (CalloutException ex) {
|
|
System.debug('An error occured ' + ex.getMessage());
|
|
}"
|
|
`;
|
|
|
|
exports[`generate request for Shell HTTPie generate GET request 1`] = `"http -a mockUser:mockPassword GET $'https://httpbin.org/path/to?a=b' $'h1:h1v' $'h2:h2v'"`;
|
|
|
|
exports[`generate request for Shell HTTPie generate POST request for JSON 1`] = `"echo -n $'{\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}' | http POST $'https://httpbin.org/path/to?a=b' 'Content-Type:application/json; charset=utf-8' $'h1:h1v' $'h2:h2v' 'Authorization:Bearer abcdefghijklmn'"`;
|
|
|
|
exports[`generate request for Shell HTTPie generate POST request for XML 1`] = `
|
|
"echo -n $'<?xml version=\\\\'1.0\\\\' encoding=\\\\'utf-8\\\\'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>' | http POST $'https://httpbin.org/path/to?a=b' 'Content-Type:application/xml; charset=utf-8' $'h1:h1v' $'h2:h2v' 'Authorization:Bearer abcdefghijklmn'"
|
|
`;
|
|
|
|
exports[`generate request for Shell HTTPie generate PUT request for www-form-urlencoded 1`] = `"echo -n $'foo=bar&baz=qux' | http PUT $'https://httpbin.org/path/to?a=b' 'Content-Type:application/x-www-form-urlencoded; charset=utf-8'"`;
|
|
|
|
exports[`generate request for cURL generate GET request 1`] = `
|
|
"curl -X GET \\\\
|
|
'https://httpbin.org/path/to?a=b' \\\\
|
|
-H 'Authorization: Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk' \\\\
|
|
-H 'h1: h1v' \\\\
|
|
-H 'h2: h2v'"
|
|
`;
|
|
|
|
exports[`generate request for cURL generate POST request for JSON 1`] = `
|
|
"curl -X POST \\\\
|
|
'https://httpbin.org/path/to?a=b' \\\\
|
|
-H 'Authorization: Bearer abcdefghijklmn' \\\\
|
|
-H 'h1: h1v' \\\\
|
|
-H 'h2: h2v' \\\\
|
|
-H 'Content-Type: application/json; charset=utf-8' \\\\
|
|
-d '{\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}'"
|
|
`;
|
|
|
|
exports[`generate request for cURL generate POST request for XML 1`] = `
|
|
"curl -X POST \\\\
|
|
'https://httpbin.org/path/to?a=b' \\\\
|
|
-H 'Authorization: Bearer abcdefghijklmn' \\\\
|
|
-H 'h1: h1v' \\\\
|
|
-H 'h2: h2v' \\\\
|
|
-H 'Content-Type: application/xml; charset=utf-8' \\\\
|
|
-d '<?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>'"
|
|
`;
|
|
|
|
exports[`generate request for cURL generate PUT request for www-form-urlencoded 1`] = `
|
|
"curl -X PUT \\\\
|
|
'https://httpbin.org/path/to?a=b' \\\\
|
|
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \\\\
|
|
-d 'foo=bar&baz=qux'"
|
|
`;
|
|
|
|
exports[`generate request for wget generate GET request 1`] = `
|
|
"wget -O - --method=GET \\\\
|
|
'https://httpbin.org/path/to?a=b' \\\\
|
|
--header='Authorization: Basic bW9ja1VzZXI6bW9ja1Bhc3N3b3Jk' \\\\
|
|
--header='h1: h1v' \\\\
|
|
--header='h2: h2v'"
|
|
`;
|
|
|
|
exports[`generate request for wget generate POST request for JSON 1`] = `
|
|
"wget -O - --method=POST \\\\
|
|
'https://httpbin.org/path/to?a=b' \\\\
|
|
--header='Authorization: Bearer abcdefghijklmn' \\\\
|
|
--header='h1: h1v' \\\\
|
|
--header='h2: h2v' \\\\
|
|
--header='Content-Type: application/json; charset=utf-8' \\\\
|
|
--body-data='{\\"foo\\": \\"bar\\", \\"baz\\": \\"qux\\"}'"
|
|
`;
|
|
|
|
exports[`generate request for wget generate POST request for XML 1`] = `
|
|
"wget -O - --method=POST \\\\
|
|
'https://httpbin.org/path/to?a=b' \\\\
|
|
--header='Authorization: Bearer abcdefghijklmn' \\\\
|
|
--header='h1: h1v' \\\\
|
|
--header='h2: h2v' \\\\
|
|
--header='Content-Type: application/xml; charset=utf-8' \\\\
|
|
--body-data='<?xml version='1.0' encoding='utf-8'?>
|
|
<xml>
|
|
<element foo=\\"bar\\"></element>
|
|
</xml>'"
|
|
`;
|
|
|
|
exports[`generate request for wget generate PUT request for www-form-urlencoded 1`] = `
|
|
"wget -O - --method=PUT \\\\
|
|
'https://httpbin.org/path/to?a=b' \\\\
|
|
--header='Content-Type: application/x-www-form-urlencoded; charset=utf-8' \\\\
|
|
--body-data='foo=bar&baz=qux'"
|
|
`;
|