Swagger Petstore [Automatic Page From File]
POST
Add a new pet to the store
{{baseUrl}}/pet
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/pet");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/pet")
require "http/client"
url = "{{baseUrl}}/pet"
response = HTTP::Client.post url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/pet"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/pet");
var request = new RestRequest("", Method.Post);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/pet"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/pet HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/pet")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/pet"))
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/pet")
.post(null)
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/pet")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/pet');
xhr.send(data);
import axios from 'axios';
const options = {method: 'POST', url: '{{baseUrl}}/pet'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/pet';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/pet',
method: 'POST',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/pet")
.post(null)
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/pet',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'POST', url: '{{baseUrl}}/pet'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/pet');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'POST', url: '{{baseUrl}}/pet'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/pet';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/pet"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/pet" in
Client.call `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/pet",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/pet');
echo $response->getBody();
setUrl('{{baseUrl}}/pet');
$request->setMethod(HTTP_METH_POST);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/pet');
$request->setRequestMethod('POST');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/pet' -Method POST
$response = Invoke-RestMethod -Uri '{{baseUrl}}/pet' -Method POST
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("POST", "/baseUrl/pet")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/pet"
response = requests.post(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/pet"
response <- VERB("POST", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/pet")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.post('/baseUrl/pet') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/pet";
let client = reqwest::Client::new();
let response = client.post(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/pet
http POST {{baseUrl}}/pet
wget --quiet \
--method POST \
--output-document \
- {{baseUrl}}/pet
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/pet")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
DELETE
Deletes a pet
{{baseUrl}}/pet/:petId
QUERY PARAMS
petId
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/pet/:petId");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/delete "{{baseUrl}}/pet/:petId")
require "http/client"
url = "{{baseUrl}}/pet/:petId"
response = HTTP::Client.delete url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Delete,
RequestUri = new Uri("{{baseUrl}}/pet/:petId"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/pet/:petId");
var request = new RestRequest("", Method.Delete);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/pet/:petId"
req, _ := http.NewRequest("DELETE", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
DELETE /baseUrl/pet/:petId HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("DELETE", "{{baseUrl}}/pet/:petId")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/pet/:petId"))
.method("DELETE", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/pet/:petId")
.delete(null)
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.delete("{{baseUrl}}/pet/:petId")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('DELETE', '{{baseUrl}}/pet/:petId');
xhr.send(data);
import axios from 'axios';
const options = {method: 'DELETE', url: '{{baseUrl}}/pet/:petId'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/pet/:petId';
const options = {method: 'DELETE'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/pet/:petId',
method: 'DELETE',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/pet/:petId")
.delete(null)
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'DELETE',
hostname: 'example.com',
port: null,
path: '/baseUrl/pet/:petId',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'DELETE', url: '{{baseUrl}}/pet/:petId'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('DELETE', '{{baseUrl}}/pet/:petId');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'DELETE', url: '{{baseUrl}}/pet/:petId'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/pet/:petId';
const options = {method: 'DELETE'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/pet/:petId"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"DELETE"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/pet/:petId" in
Client.call `DELETE uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/pet/:petId",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('DELETE', '{{baseUrl}}/pet/:petId');
echo $response->getBody();
setUrl('{{baseUrl}}/pet/:petId');
$request->setMethod(HTTP_METH_DELETE);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/pet/:petId');
$request->setRequestMethod('DELETE');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/pet/:petId' -Method DELETE
$response = Invoke-RestMethod -Uri '{{baseUrl}}/pet/:petId' -Method DELETE
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("DELETE", "/baseUrl/pet/:petId")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/pet/:petId"
response = requests.delete(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/pet/:petId"
response <- VERB("DELETE", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/pet/:petId")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.delete('/baseUrl/pet/:petId') do |req|
end
puts response.status
puts response.body
use std::str::FromStr;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/pet/:petId";
let client = reqwest::Client::new();
let response = client.request(reqwest::Method::from_str("DELETE").unwrap(), url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request DELETE \
--url {{baseUrl}}/pet/:petId
http DELETE {{baseUrl}}/pet/:petId
wget --quiet \
--method DELETE \
--output-document \
- {{baseUrl}}/pet/:petId
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/pet/:petId")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "DELETE"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
GET
Find pet by ID
{{baseUrl}}/pet/:petId
HEADERS
api_key
{{apiKey}}
QUERY PARAMS
petId
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/pet/:petId");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "api_key: {{apiKey}}");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/pet/:petId" {:headers {:api_key "{{apiKey}}"}})
require "http/client"
url = "{{baseUrl}}/pet/:petId"
headers = HTTP::Headers{
"api_key" => "{{apiKey}}"
}
response = HTTP::Client.get url, headers: headers
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/pet/:petId"),
Headers =
{
{ "api_key", "{{apiKey}}" },
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/pet/:petId");
var request = new RestRequest("", Method.Get);
request.AddHeader("api_key", "{{apiKey}}");
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/pet/:petId"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("api_key", "{{apiKey}}")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/pet/:petId HTTP/1.1
Api_key: {{apiKey}}
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/pet/:petId")
.setHeader("api_key", "{{apiKey}}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/pet/:petId"))
.header("api_key", "{{apiKey}}")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/pet/:petId")
.get()
.addHeader("api_key", "{{apiKey}}")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/pet/:petId")
.header("api_key", "{{apiKey}}")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/pet/:petId');
xhr.setRequestHeader('api_key', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'GET',
url: '{{baseUrl}}/pet/:petId',
headers: {api_key: '{{apiKey}}'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/pet/:petId';
const options = {method: 'GET', headers: {api_key: '{{apiKey}}'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/pet/:petId',
method: 'GET',
headers: {
api_key: '{{apiKey}}'
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/pet/:petId")
.get()
.addHeader("api_key", "{{apiKey}}")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/pet/:petId',
headers: {
api_key: '{{apiKey}}'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'GET',
url: '{{baseUrl}}/pet/:petId',
headers: {api_key: '{{apiKey}}'}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/pet/:petId');
req.headers({
api_key: '{{apiKey}}'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'GET',
url: '{{baseUrl}}/pet/:petId',
headers: {api_key: '{{apiKey}}'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/pet/:petId';
const options = {method: 'GET', headers: {api_key: '{{apiKey}}'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"api_key": @"{{apiKey}}" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/pet/:petId"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/pet/:petId" in
let headers = Header.add (Header.init ()) "api_key" "{{apiKey}}" in
Client.call ~headers `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/pet/:petId",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"api_key: {{apiKey}}"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/pet/:petId', [
'headers' => [
'api_key' => '{{apiKey}}',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/pet/:petId');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders([
'api_key' => '{{apiKey}}'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/pet/:petId');
$request->setRequestMethod('GET');
$request->setHeaders([
'api_key' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("api_key", "{{apiKey}}")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/pet/:petId' -Method GET -Headers $headers
$headers=@{}
$headers.Add("api_key", "{{apiKey}}")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/pet/:petId' -Method GET -Headers $headers
import http.client
conn = http.client.HTTPSConnection("example.com")
headers = { 'api_key': "{{apiKey}}" }
conn.request("GET", "/baseUrl/pet/:petId", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/pet/:petId"
headers = {"api_key": "{{apiKey}}"}
response = requests.get(url, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/pet/:petId"
response <- VERB("GET", url, add_headers('api_key' = '{{apiKey}}'), content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/pet/:petId")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["api_key"] = '{{apiKey}}'
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/pet/:petId') do |req|
req.headers['api_key'] = '{{apiKey}}'
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/pet/:petId";
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("api_key", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.get(url)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/pet/:petId \
--header 'api_key: {{apiKey}}'
http GET {{baseUrl}}/pet/:petId \
api_key:'{{apiKey}}'
wget --quiet \
--method GET \
--header 'api_key: {{apiKey}}' \
--output-document \
- {{baseUrl}}/pet/:petId
import Foundation
let headers = ["api_key": "{{apiKey}}"]
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/pet/:petId")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
GET
Finds Pets by status
{{baseUrl}}/pet/findByStatus
QUERY PARAMS
status
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/pet/findByStatus?status=");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/pet/findByStatus" {:query-params {:status ""}})
require "http/client"
url = "{{baseUrl}}/pet/findByStatus?status="
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/pet/findByStatus?status="),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/pet/findByStatus?status=");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/pet/findByStatus?status="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/pet/findByStatus?status= HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/pet/findByStatus?status=")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/pet/findByStatus?status="))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/pet/findByStatus?status=")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/pet/findByStatus?status=")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/pet/findByStatus?status=');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'GET',
url: '{{baseUrl}}/pet/findByStatus',
params: {status: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/pet/findByStatus?status=';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/pet/findByStatus?status=',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/pet/findByStatus?status=")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/pet/findByStatus?status=',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'GET',
url: '{{baseUrl}}/pet/findByStatus',
qs: {status: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/pet/findByStatus');
req.query({
status: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'GET',
url: '{{baseUrl}}/pet/findByStatus',
params: {status: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/pet/findByStatus?status=';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/pet/findByStatus?status="]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/pet/findByStatus?status=" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/pet/findByStatus?status=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/pet/findByStatus?status=');
echo $response->getBody();
setUrl('{{baseUrl}}/pet/findByStatus');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData([
'status' => ''
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/pet/findByStatus');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString([
'status' => ''
]));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/pet/findByStatus?status=' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/pet/findByStatus?status=' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/pet/findByStatus?status=")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/pet/findByStatus"
querystring = {"status":""}
response = requests.get(url, params=querystring)
print(response.json())
library(httr)
url <- "{{baseUrl}}/pet/findByStatus"
queryString <- list(status = "")
response <- VERB("GET", url, query = queryString, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/pet/findByStatus?status=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/pet/findByStatus') do |req|
req.params['status'] = ''
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/pet/findByStatus";
let querystring = [
("status", ""),
];
let client = reqwest::Client::new();
let response = client.get(url)
.query(&querystring)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url '{{baseUrl}}/pet/findByStatus?status='
http GET '{{baseUrl}}/pet/findByStatus?status='
wget --quiet \
--method GET \
--output-document \
- '{{baseUrl}}/pet/findByStatus?status='
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/pet/findByStatus?status=")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
GET
Finds Pets by tags
{{baseUrl}}/pet/findByTags
QUERY PARAMS
tags
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/pet/findByTags?tags=");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/pet/findByTags" {:query-params {:tags ""}})
require "http/client"
url = "{{baseUrl}}/pet/findByTags?tags="
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/pet/findByTags?tags="),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/pet/findByTags?tags=");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/pet/findByTags?tags="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/pet/findByTags?tags= HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/pet/findByTags?tags=")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/pet/findByTags?tags="))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/pet/findByTags?tags=")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/pet/findByTags?tags=")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/pet/findByTags?tags=');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'GET',
url: '{{baseUrl}}/pet/findByTags',
params: {tags: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/pet/findByTags?tags=';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/pet/findByTags?tags=',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/pet/findByTags?tags=")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/pet/findByTags?tags=',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'GET',
url: '{{baseUrl}}/pet/findByTags',
qs: {tags: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/pet/findByTags');
req.query({
tags: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'GET',
url: '{{baseUrl}}/pet/findByTags',
params: {tags: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/pet/findByTags?tags=';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/pet/findByTags?tags="]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/pet/findByTags?tags=" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/pet/findByTags?tags=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/pet/findByTags?tags=');
echo $response->getBody();
setUrl('{{baseUrl}}/pet/findByTags');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData([
'tags' => ''
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/pet/findByTags');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString([
'tags' => ''
]));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/pet/findByTags?tags=' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/pet/findByTags?tags=' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/pet/findByTags?tags=")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/pet/findByTags"
querystring = {"tags":""}
response = requests.get(url, params=querystring)
print(response.json())
library(httr)
url <- "{{baseUrl}}/pet/findByTags"
queryString <- list(tags = "")
response <- VERB("GET", url, query = queryString, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/pet/findByTags?tags=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/pet/findByTags') do |req|
req.params['tags'] = ''
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/pet/findByTags";
let querystring = [
("tags", ""),
];
let client = reqwest::Client::new();
let response = client.get(url)
.query(&querystring)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url '{{baseUrl}}/pet/findByTags?tags='
http GET '{{baseUrl}}/pet/findByTags?tags='
wget --quiet \
--method GET \
--output-document \
- '{{baseUrl}}/pet/findByTags?tags='
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/pet/findByTags?tags=")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
PUT
Update an existing pet
{{baseUrl}}/pet
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/pet");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/put "{{baseUrl}}/pet")
require "http/client"
url = "{{baseUrl}}/pet"
response = HTTP::Client.put url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Put,
RequestUri = new Uri("{{baseUrl}}/pet"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/pet");
var request = new RestRequest("", Method.Put);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/pet"
req, _ := http.NewRequest("PUT", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
PUT /baseUrl/pet HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("PUT", "{{baseUrl}}/pet")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/pet"))
.method("PUT", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/pet")
.put(null)
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.put("{{baseUrl}}/pet")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('PUT', '{{baseUrl}}/pet');
xhr.send(data);
import axios from 'axios';
const options = {method: 'PUT', url: '{{baseUrl}}/pet'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/pet';
const options = {method: 'PUT'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/pet',
method: 'PUT',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/pet")
.put(null)
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'PUT',
hostname: 'example.com',
port: null,
path: '/baseUrl/pet',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'PUT', url: '{{baseUrl}}/pet'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('PUT', '{{baseUrl}}/pet');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'PUT', url: '{{baseUrl}}/pet'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/pet';
const options = {method: 'PUT'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/pet"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"PUT"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/pet" in
Client.call `PUT uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/pet",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('PUT', '{{baseUrl}}/pet');
echo $response->getBody();
setUrl('{{baseUrl}}/pet');
$request->setMethod(HTTP_METH_PUT);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/pet');
$request->setRequestMethod('PUT');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/pet' -Method PUT
$response = Invoke-RestMethod -Uri '{{baseUrl}}/pet' -Method PUT
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("PUT", "/baseUrl/pet")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/pet"
response = requests.put(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/pet"
response <- VERB("PUT", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/pet")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.put('/baseUrl/pet') do |req|
end
puts response.status
puts response.body
use std::str::FromStr;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/pet";
let client = reqwest::Client::new();
let response = client.request(reqwest::Method::from_str("PUT").unwrap(), url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request PUT \
--url {{baseUrl}}/pet
http PUT {{baseUrl}}/pet
wget --quiet \
--method PUT \
--output-document \
- {{baseUrl}}/pet
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/pet")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PUT"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Updates a pet in the store with form data
{{baseUrl}}/pet/:petId
QUERY PARAMS
petId
BODY formUrlEncoded
name
status
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/pet/:petId");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/x-www-form-urlencoded");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "name=&status=");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/pet/:petId" {:form-params {:name ""
:status ""}})
require "http/client"
url = "{{baseUrl}}/pet/:petId"
headers = HTTP::Headers{
"content-type" => "application/x-www-form-urlencoded"
}
reqBody = "name=&status="
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/pet/:petId"),
Content = new FormUrlEncodedContent(new Dictionary
{
{ "name", "" },
{ "status", "" },
}),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/pet/:petId");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "name=&status=", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/pet/:petId"
payload := strings.NewReader("name=&status=")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/pet/:petId HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: example.com
Content-Length: 13
name=&status=
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/pet/:petId")
.setHeader("content-type", "application/x-www-form-urlencoded")
.setBody("name=&status=")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/pet/:petId"))
.header("content-type", "application/x-www-form-urlencoded")
.method("POST", HttpRequest.BodyPublishers.ofString("name=&status="))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "name=&status=");
Request request = new Request.Builder()
.url("{{baseUrl}}/pet/:petId")
.post(body)
.addHeader("content-type", "application/x-www-form-urlencoded")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/pet/:petId")
.header("content-type", "application/x-www-form-urlencoded")
.body("name=&status=")
.asString();
const data = 'name=&status=';
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/pet/:petId');
xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
xhr.send(data);
import axios from 'axios';
const encodedParams = new URLSearchParams();
encodedParams.set('name', '');
encodedParams.set('status', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/pet/:petId',
headers: {'content-type': 'application/x-www-form-urlencoded'},
data: encodedParams,
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/pet/:petId';
const options = {
method: 'POST',
headers: {'content-type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({name: '', status: ''})
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/pet/:petId',
method: 'POST',
headers: {
'content-type': 'application/x-www-form-urlencoded'
},
data: {
name: '',
status: ''
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/x-www-form-urlencoded")
val body = RequestBody.create(mediaType, "name=&status=")
val request = Request.Builder()
.url("{{baseUrl}}/pet/:petId")
.post(body)
.addHeader("content-type", "application/x-www-form-urlencoded")
.build()
val response = client.newCall(request).execute()
const qs = require('querystring');
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/pet/:petId',
headers: {
'content-type': 'application/x-www-form-urlencoded'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(qs.stringify({name: '', status: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/pet/:petId',
headers: {'content-type': 'application/x-www-form-urlencoded'},
form: {name: '', status: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/pet/:petId');
req.headers({
'content-type': 'application/x-www-form-urlencoded'
});
req.form({
name: '',
status: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const { URLSearchParams } = require('url');
const encodedParams = new URLSearchParams();
encodedParams.set('name', '');
encodedParams.set('status', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/pet/:petId',
headers: {'content-type': 'application/x-www-form-urlencoded'},
data: encodedParams,
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const { URLSearchParams } = require('url');
const fetch = require('node-fetch');
const encodedParams = new URLSearchParams();
encodedParams.set('name', '');
encodedParams.set('status', '');
const url = '{{baseUrl}}/pet/:petId';
const options = {
method: 'POST',
headers: {'content-type': 'application/x-www-form-urlencoded'},
body: encodedParams
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/x-www-form-urlencoded" };
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"name=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&status=" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/pet/:petId"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/pet/:petId" in
let headers = Header.add (Header.init ()) "content-type" "application/x-www-form-urlencoded" in
let body = Cohttp_lwt_body.of_string "name=&status=" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/pet/:petId",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "name=&status=",
CURLOPT_HTTPHEADER => [
"content-type: application/x-www-form-urlencoded"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/pet/:petId', [
'form_params' => [
'name' => '',
'status' => ''
],
'headers' => [
'content-type' => 'application/x-www-form-urlencoded',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/pet/:petId');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/x-www-form-urlencoded'
]);
$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields([
'name' => '',
'status' => ''
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(new http\QueryString([
'name' => '',
'status' => ''
]));
$request->setRequestUrl('{{baseUrl}}/pet/:petId');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/x-www-form-urlencoded'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/x-www-form-urlencoded")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/pet/:petId' -Method POST -Headers $headers -ContentType 'application/x-www-form-urlencoded' -Body 'name=&status='
$headers=@{}
$headers.Add("content-type", "application/x-www-form-urlencoded")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/pet/:petId' -Method POST -Headers $headers -ContentType 'application/x-www-form-urlencoded' -Body 'name=&status='
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "name=&status="
headers = { 'content-type': "application/x-www-form-urlencoded" }
conn.request("POST", "/baseUrl/pet/:petId", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/pet/:petId"
payload = {
"name": "",
"status": ""
}
headers = {"content-type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/pet/:petId"
payload <- "name=&status="
encode <- "form"
response <- VERB("POST", url, body = payload, content_type("application/x-www-form-urlencoded"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/pet/:petId")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/x-www-form-urlencoded'
request.body = "name=&status="
response = http.request(request)
puts response.read_body
require 'faraday'
data = {
:name => "",
:status => "",
}
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/x-www-form-urlencoded'}
)
response = conn.post('/baseUrl/pet/:petId') do |req|
req.body = URI.encode_www_form(data)
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/pet/:petId";
let payload = json!({
"name": "",
"status": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/x-www-form-urlencoded".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.form(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/pet/:petId \
--header 'content-type: application/x-www-form-urlencoded' \
--data name= \
--data status=
http --form POST {{baseUrl}}/pet/:petId \
content-type:application/x-www-form-urlencoded \
name='' \
status=''
wget --quiet \
--method POST \
--header 'content-type: application/x-www-form-urlencoded' \
--body-data 'name=&status=' \
--output-document \
- {{baseUrl}}/pet/:petId
import Foundation
let headers = ["content-type": "application/x-www-form-urlencoded"]
let postData = NSMutableData(data: "name=".data(using: String.Encoding.utf8)!)
postData.append("&status=".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/pet/:petId")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
uploads an image
{{baseUrl}}/pet/:petId/uploadImage
QUERY PARAMS
petId
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/pet/:petId/uploadImage");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/pet/:petId/uploadImage")
require "http/client"
url = "{{baseUrl}}/pet/:petId/uploadImage"
response = HTTP::Client.post url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/pet/:petId/uploadImage"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/pet/:petId/uploadImage");
var request = new RestRequest("", Method.Post);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/pet/:petId/uploadImage"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/pet/:petId/uploadImage HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/pet/:petId/uploadImage")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/pet/:petId/uploadImage"))
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/pet/:petId/uploadImage")
.post(null)
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/pet/:petId/uploadImage")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/pet/:petId/uploadImage');
xhr.send(data);
import axios from 'axios';
const options = {method: 'POST', url: '{{baseUrl}}/pet/:petId/uploadImage'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/pet/:petId/uploadImage';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/pet/:petId/uploadImage',
method: 'POST',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/pet/:petId/uploadImage")
.post(null)
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/pet/:petId/uploadImage',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'POST', url: '{{baseUrl}}/pet/:petId/uploadImage'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/pet/:petId/uploadImage');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'POST', url: '{{baseUrl}}/pet/:petId/uploadImage'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/pet/:petId/uploadImage';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/pet/:petId/uploadImage"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/pet/:petId/uploadImage" in
Client.call `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/pet/:petId/uploadImage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/pet/:petId/uploadImage');
echo $response->getBody();
setUrl('{{baseUrl}}/pet/:petId/uploadImage');
$request->setMethod(HTTP_METH_POST);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/pet/:petId/uploadImage');
$request->setRequestMethod('POST');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/pet/:petId/uploadImage' -Method POST
$response = Invoke-RestMethod -Uri '{{baseUrl}}/pet/:petId/uploadImage' -Method POST
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("POST", "/baseUrl/pet/:petId/uploadImage")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/pet/:petId/uploadImage"
response = requests.post(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/pet/:petId/uploadImage"
response <- VERB("POST", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/pet/:petId/uploadImage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.post('/baseUrl/pet/:petId/uploadImage') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/pet/:petId/uploadImage";
let client = reqwest::Client::new();
let response = client.post(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/pet/:petId/uploadImage
http POST {{baseUrl}}/pet/:petId/uploadImage
wget --quiet \
--method POST \
--output-document \
- {{baseUrl}}/pet/:petId/uploadImage
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/pet/:petId/uploadImage")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
DELETE
Delete purchase order by ID
{{baseUrl}}/store/order/:orderId
QUERY PARAMS
orderId
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/store/order/:orderId");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/delete "{{baseUrl}}/store/order/:orderId")
require "http/client"
url = "{{baseUrl}}/store/order/:orderId"
response = HTTP::Client.delete url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Delete,
RequestUri = new Uri("{{baseUrl}}/store/order/:orderId"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/store/order/:orderId");
var request = new RestRequest("", Method.Delete);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/store/order/:orderId"
req, _ := http.NewRequest("DELETE", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
DELETE /baseUrl/store/order/:orderId HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("DELETE", "{{baseUrl}}/store/order/:orderId")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/store/order/:orderId"))
.method("DELETE", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/store/order/:orderId")
.delete(null)
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.delete("{{baseUrl}}/store/order/:orderId")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('DELETE', '{{baseUrl}}/store/order/:orderId');
xhr.send(data);
import axios from 'axios';
const options = {method: 'DELETE', url: '{{baseUrl}}/store/order/:orderId'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/store/order/:orderId';
const options = {method: 'DELETE'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/store/order/:orderId',
method: 'DELETE',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/store/order/:orderId")
.delete(null)
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'DELETE',
hostname: 'example.com',
port: null,
path: '/baseUrl/store/order/:orderId',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'DELETE', url: '{{baseUrl}}/store/order/:orderId'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('DELETE', '{{baseUrl}}/store/order/:orderId');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'DELETE', url: '{{baseUrl}}/store/order/:orderId'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/store/order/:orderId';
const options = {method: 'DELETE'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/store/order/:orderId"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"DELETE"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/store/order/:orderId" in
Client.call `DELETE uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/store/order/:orderId",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('DELETE', '{{baseUrl}}/store/order/:orderId');
echo $response->getBody();
setUrl('{{baseUrl}}/store/order/:orderId');
$request->setMethod(HTTP_METH_DELETE);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/store/order/:orderId');
$request->setRequestMethod('DELETE');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/store/order/:orderId' -Method DELETE
$response = Invoke-RestMethod -Uri '{{baseUrl}}/store/order/:orderId' -Method DELETE
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("DELETE", "/baseUrl/store/order/:orderId")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/store/order/:orderId"
response = requests.delete(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/store/order/:orderId"
response <- VERB("DELETE", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/store/order/:orderId")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.delete('/baseUrl/store/order/:orderId') do |req|
end
puts response.status
puts response.body
use std::str::FromStr;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/store/order/:orderId";
let client = reqwest::Client::new();
let response = client.request(reqwest::Method::from_str("DELETE").unwrap(), url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request DELETE \
--url {{baseUrl}}/store/order/:orderId
http DELETE {{baseUrl}}/store/order/:orderId
wget --quiet \
--method DELETE \
--output-document \
- {{baseUrl}}/store/order/:orderId
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/store/order/:orderId")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "DELETE"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
GET
Find purchase order by ID
{{baseUrl}}/store/order/:orderId
QUERY PARAMS
orderId
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/store/order/:orderId");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/store/order/:orderId")
require "http/client"
url = "{{baseUrl}}/store/order/:orderId"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/store/order/:orderId"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/store/order/:orderId");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/store/order/:orderId"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/store/order/:orderId HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/store/order/:orderId")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/store/order/:orderId"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/store/order/:orderId")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/store/order/:orderId")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/store/order/:orderId');
xhr.send(data);
import axios from 'axios';
const options = {method: 'GET', url: '{{baseUrl}}/store/order/:orderId'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/store/order/:orderId';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/store/order/:orderId',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/store/order/:orderId")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/store/order/:orderId',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'GET', url: '{{baseUrl}}/store/order/:orderId'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/store/order/:orderId');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'GET', url: '{{baseUrl}}/store/order/:orderId'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/store/order/:orderId';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/store/order/:orderId"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/store/order/:orderId" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/store/order/:orderId",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/store/order/:orderId');
echo $response->getBody();
setUrl('{{baseUrl}}/store/order/:orderId');
$request->setMethod(HTTP_METH_GET);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/store/order/:orderId');
$request->setRequestMethod('GET');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/store/order/:orderId' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/store/order/:orderId' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/store/order/:orderId")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/store/order/:orderId"
response = requests.get(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/store/order/:orderId"
response <- VERB("GET", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/store/order/:orderId")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/store/order/:orderId') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/store/order/:orderId";
let client = reqwest::Client::new();
let response = client.get(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/store/order/:orderId
http GET {{baseUrl}}/store/order/:orderId
wget --quiet \
--method GET \
--output-document \
- {{baseUrl}}/store/order/:orderId
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/store/order/:orderId")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Place an order for a pet
{{baseUrl}}/store/order
BODY json
{
"id": "",
"petId": "",
"quantity": 0,
"shipDate": "",
"status": "",
"complete": false,
"requestId": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/store/order");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/store/order" {:content-type :json
:form-params {:id ""
:petId ""
:quantity 0
:shipDate ""
:status ""
:complete false
:requestId ""}})
require "http/client"
url = "{{baseUrl}}/store/order"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/store/order"),
Content = new StringContent("{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/store/order");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/store/order"
payload := strings.NewReader("{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/store/order HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 120
{
"id": "",
"petId": "",
"quantity": 0,
"shipDate": "",
"status": "",
"complete": false,
"requestId": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/store/order")
.setHeader("content-type", "application/json")
.setBody("{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/store/order"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/store/order")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/store/order")
.header("content-type", "application/json")
.body("{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}")
.asString();
const data = JSON.stringify({
id: '',
petId: '',
quantity: 0,
shipDate: '',
status: '',
complete: false,
requestId: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/store/order');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/store/order',
headers: {'content-type': 'application/json'},
data: {
id: '',
petId: '',
quantity: 0,
shipDate: '',
status: '',
complete: false,
requestId: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/store/order';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"id":"","petId":"","quantity":0,"shipDate":"","status":"","complete":false,"requestId":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/store/order',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "id": "",\n "petId": "",\n "quantity": 0,\n "shipDate": "",\n "status": "",\n "complete": false,\n "requestId": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/store/order")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/store/order',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
id: '',
petId: '',
quantity: 0,
shipDate: '',
status: '',
complete: false,
requestId: ''
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/store/order',
headers: {'content-type': 'application/json'},
body: {
id: '',
petId: '',
quantity: 0,
shipDate: '',
status: '',
complete: false,
requestId: ''
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/store/order');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
id: '',
petId: '',
quantity: 0,
shipDate: '',
status: '',
complete: false,
requestId: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/store/order',
headers: {'content-type': 'application/json'},
data: {
id: '',
petId: '',
quantity: 0,
shipDate: '',
status: '',
complete: false,
requestId: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/store/order';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"id":"","petId":"","quantity":0,"shipDate":"","status":"","complete":false,"requestId":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"id": @"",
@"petId": @"",
@"quantity": @0,
@"shipDate": @"",
@"status": @"",
@"complete": @NO,
@"requestId": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/store/order"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/store/order" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/store/order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => '',
'petId' => '',
'quantity' => 0,
'shipDate' => '',
'status' => '',
'complete' => null,
'requestId' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/store/order', [
'body' => '{
"id": "",
"petId": "",
"quantity": 0,
"shipDate": "",
"status": "",
"complete": false,
"requestId": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/store/order');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'id' => '',
'petId' => '',
'quantity' => 0,
'shipDate' => '',
'status' => '',
'complete' => null,
'requestId' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'id' => '',
'petId' => '',
'quantity' => 0,
'shipDate' => '',
'status' => '',
'complete' => null,
'requestId' => ''
]));
$request->setRequestUrl('{{baseUrl}}/store/order');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/store/order' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"id": "",
"petId": "",
"quantity": 0,
"shipDate": "",
"status": "",
"complete": false,
"requestId": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/store/order' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"id": "",
"petId": "",
"quantity": 0,
"shipDate": "",
"status": "",
"complete": false,
"requestId": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/store/order", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/store/order"
payload = {
"id": "",
"petId": "",
"quantity": 0,
"shipDate": "",
"status": "",
"complete": False,
"requestId": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/store/order"
payload <- "{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/store/order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/store/order') do |req|
req.body = "{\n \"id\": \"\",\n \"petId\": \"\",\n \"quantity\": 0,\n \"shipDate\": \"\",\n \"status\": \"\",\n \"complete\": false,\n \"requestId\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/store/order";
let payload = json!({
"id": "",
"petId": "",
"quantity": 0,
"shipDate": "",
"status": "",
"complete": false,
"requestId": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/store/order \
--header 'content-type: application/json' \
--data '{
"id": "",
"petId": "",
"quantity": 0,
"shipDate": "",
"status": "",
"complete": false,
"requestId": ""
}'
echo '{
"id": "",
"petId": "",
"quantity": 0,
"shipDate": "",
"status": "",
"complete": false,
"requestId": ""
}' | \
http POST {{baseUrl}}/store/order \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "id": "",\n "petId": "",\n "quantity": 0,\n "shipDate": "",\n "status": "",\n "complete": false,\n "requestId": ""\n}' \
--output-document \
- {{baseUrl}}/store/order
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"id": "",
"petId": "",
"quantity": 0,
"shipDate": "",
"status": "",
"complete": false,
"requestId": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/store/order")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"status": 400,
"message": "Invalid Order"
}
GET
Returns pet inventories by status
{{baseUrl}}/store/inventory
HEADERS
api_key
{{apiKey}}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/store/inventory");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "api_key: {{apiKey}}");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/store/inventory" {:headers {:api_key "{{apiKey}}"}})
require "http/client"
url = "{{baseUrl}}/store/inventory"
headers = HTTP::Headers{
"api_key" => "{{apiKey}}"
}
response = HTTP::Client.get url, headers: headers
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/store/inventory"),
Headers =
{
{ "api_key", "{{apiKey}}" },
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/store/inventory");
var request = new RestRequest("", Method.Get);
request.AddHeader("api_key", "{{apiKey}}");
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/store/inventory"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("api_key", "{{apiKey}}")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/store/inventory HTTP/1.1
Api_key: {{apiKey}}
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/store/inventory")
.setHeader("api_key", "{{apiKey}}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/store/inventory"))
.header("api_key", "{{apiKey}}")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/store/inventory")
.get()
.addHeader("api_key", "{{apiKey}}")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/store/inventory")
.header("api_key", "{{apiKey}}")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/store/inventory');
xhr.setRequestHeader('api_key', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'GET',
url: '{{baseUrl}}/store/inventory',
headers: {api_key: '{{apiKey}}'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/store/inventory';
const options = {method: 'GET', headers: {api_key: '{{apiKey}}'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/store/inventory',
method: 'GET',
headers: {
api_key: '{{apiKey}}'
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/store/inventory")
.get()
.addHeader("api_key", "{{apiKey}}")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/store/inventory',
headers: {
api_key: '{{apiKey}}'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'GET',
url: '{{baseUrl}}/store/inventory',
headers: {api_key: '{{apiKey}}'}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/store/inventory');
req.headers({
api_key: '{{apiKey}}'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'GET',
url: '{{baseUrl}}/store/inventory',
headers: {api_key: '{{apiKey}}'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/store/inventory';
const options = {method: 'GET', headers: {api_key: '{{apiKey}}'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"api_key": @"{{apiKey}}" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/store/inventory"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/store/inventory" in
let headers = Header.add (Header.init ()) "api_key" "{{apiKey}}" in
Client.call ~headers `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/store/inventory",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"api_key: {{apiKey}}"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/store/inventory', [
'headers' => [
'api_key' => '{{apiKey}}',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/store/inventory');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders([
'api_key' => '{{apiKey}}'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/store/inventory');
$request->setRequestMethod('GET');
$request->setHeaders([
'api_key' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("api_key", "{{apiKey}}")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/store/inventory' -Method GET -Headers $headers
$headers=@{}
$headers.Add("api_key", "{{apiKey}}")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/store/inventory' -Method GET -Headers $headers
import http.client
conn = http.client.HTTPSConnection("example.com")
headers = { 'api_key': "{{apiKey}}" }
conn.request("GET", "/baseUrl/store/inventory", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/store/inventory"
headers = {"api_key": "{{apiKey}}"}
response = requests.get(url, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/store/inventory"
response <- VERB("GET", url, add_headers('api_key' = '{{apiKey}}'), content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/store/inventory")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["api_key"] = '{{apiKey}}'
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/store/inventory') do |req|
req.headers['api_key'] = '{{apiKey}}'
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/store/inventory";
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("api_key", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.get(url)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/store/inventory \
--header 'api_key: {{apiKey}}'
http GET {{baseUrl}}/store/inventory \
api_key:'{{apiKey}}'
wget --quiet \
--method GET \
--header 'api_key: {{apiKey}}' \
--output-document \
- {{baseUrl}}/store/inventory
import Foundation
let headers = ["api_key": "{{apiKey}}"]
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/store/inventory")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Subscribe to the Store events
{{baseUrl}}/store/subscribe
BODY json
{
"callbackUrl": "",
"eventName": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/store/subscribe");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/store/subscribe" {:content-type :json
:form-params {:callbackUrl ""
:eventName ""}})
require "http/client"
url = "{{baseUrl}}/store/subscribe"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/store/subscribe"),
Content = new StringContent("{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/store/subscribe");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/store/subscribe"
payload := strings.NewReader("{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/store/subscribe HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 42
{
"callbackUrl": "",
"eventName": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/store/subscribe")
.setHeader("content-type", "application/json")
.setBody("{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/store/subscribe"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/store/subscribe")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/store/subscribe")
.header("content-type", "application/json")
.body("{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}")
.asString();
const data = JSON.stringify({
callbackUrl: '',
eventName: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/store/subscribe');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/store/subscribe',
headers: {'content-type': 'application/json'},
data: {callbackUrl: '', eventName: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/store/subscribe';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"callbackUrl":"","eventName":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/store/subscribe',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "callbackUrl": "",\n "eventName": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/store/subscribe")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/store/subscribe',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({callbackUrl: '', eventName: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/store/subscribe',
headers: {'content-type': 'application/json'},
body: {callbackUrl: '', eventName: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/store/subscribe');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
callbackUrl: '',
eventName: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/store/subscribe',
headers: {'content-type': 'application/json'},
data: {callbackUrl: '', eventName: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/store/subscribe';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"callbackUrl":"","eventName":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"callbackUrl": @"",
@"eventName": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/store/subscribe"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/store/subscribe" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/store/subscribe",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'callbackUrl' => '',
'eventName' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/store/subscribe', [
'body' => '{
"callbackUrl": "",
"eventName": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/store/subscribe');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'callbackUrl' => '',
'eventName' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'callbackUrl' => '',
'eventName' => ''
]));
$request->setRequestUrl('{{baseUrl}}/store/subscribe');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/store/subscribe' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"callbackUrl": "",
"eventName": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/store/subscribe' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"callbackUrl": "",
"eventName": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/store/subscribe", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/store/subscribe"
payload = {
"callbackUrl": "",
"eventName": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/store/subscribe"
payload <- "{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/store/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/store/subscribe') do |req|
req.body = "{\n \"callbackUrl\": \"\",\n \"eventName\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/store/subscribe";
let payload = json!({
"callbackUrl": "",
"eventName": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/store/subscribe \
--header 'content-type: application/json' \
--data '{
"callbackUrl": "",
"eventName": ""
}'
echo '{
"callbackUrl": "",
"eventName": ""
}' | \
http POST {{baseUrl}}/store/subscribe \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "callbackUrl": "",\n "eventName": ""\n}' \
--output-document \
- {{baseUrl}}/store/subscribe
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"callbackUrl": "",
"eventName": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/store/subscribe")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"subscriptionId": "AAA-123-BBB-456"
}
POST
Create user
{{baseUrl}}/user
BODY json
{
"id": "",
"pet": "",
"username": "",
"firstName": "",
"lastName": "",
"email": "",
"password": "",
"phone": "",
"userStatus": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/user");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/user" {:content-type :json
:form-params {:username "John78"
:firstName "John"
:lastName "Smith"
:email "john.smith@example.com"
:password "drowssaP123"
:phone "+1-202-555-0192"}})
require "http/client"
url = "{{baseUrl}}/user"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/user"),
Content = new StringContent("{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/user");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/user"
payload := strings.NewReader("{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/user HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 168
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/user")
.setHeader("content-type", "application/json")
.setBody("{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/user"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/user")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/user")
.header("content-type", "application/json")
.body("{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}")
.asString();
const data = JSON.stringify({
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/user');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/user',
headers: {'content-type': 'application/json'},
data: {
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/user';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"username":"John78","firstName":"John","lastName":"Smith","email":"john.smith@example.com","password":"drowssaP123","phone":"+1-202-555-0192"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/user',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "username": "John78",\n "firstName": "John",\n "lastName": "Smith",\n "email": "john.smith@example.com",\n "password": "drowssaP123",\n "phone": "+1-202-555-0192"\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/user")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/user',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/user',
headers: {'content-type': 'application/json'},
body: {
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/user');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/user',
headers: {'content-type': 'application/json'},
data: {
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/user';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"username":"John78","firstName":"John","lastName":"Smith","email":"john.smith@example.com","password":"drowssaP123","phone":"+1-202-555-0192"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"username": @"John78",
@"firstName": @"John",
@"lastName": @"Smith",
@"email": @"john.smith@example.com",
@"password": @"drowssaP123",
@"phone": @"+1-202-555-0192" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/user"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/user" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/user",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/user', [
'body' => '{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/user');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]));
$request->setRequestUrl('{{baseUrl}}/user');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/user' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/user' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/user", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/user"
payload = {
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/user"
payload <- "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/user")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/user') do |req|
req.body = "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/user";
let payload = json!({
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/user \
--header 'content-type: application/json' \
--data '{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}'
echo '{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}' | \
http POST {{baseUrl}}/user \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "username": "John78",\n "firstName": "John",\n "lastName": "Smith",\n "email": "john.smith@example.com",\n "password": "drowssaP123",\n "phone": "+1-202-555-0192"\n}' \
--output-document \
- {{baseUrl}}/user
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/user")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Creates list of users with given input array (POST)
{{baseUrl}}/user/createWithList
BODY json
[
{
"id": "",
"pet": "",
"username": "",
"firstName": "",
"lastName": "",
"email": "",
"password": "",
"phone": "",
"userStatus": 0
}
]
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/user/createWithList");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/user/createWithList" {:content-type :json
:form-params [{:username "John78"
:firstName "John"
:lastName "Smith"
:email "john.smith@example.com"
:password "drowssaP123"
:phone "+1-202-555-0192"}]})
require "http/client"
url = "{{baseUrl}}/user/createWithList"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/user/createWithList"),
Content = new StringContent("[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/user/createWithList");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/user/createWithList"
payload := strings.NewReader("[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/user/createWithList HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 188
[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/user/createWithList")
.setHeader("content-type", "application/json")
.setBody("[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/user/createWithList"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]");
Request request = new Request.Builder()
.url("{{baseUrl}}/user/createWithList")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/user/createWithList")
.header("content-type", "application/json")
.body("[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]")
.asString();
const data = JSON.stringify([
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
]);
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/user/createWithList');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/user/createWithList',
headers: {'content-type': 'application/json'},
data: [
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/user/createWithList';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"username":"John78","firstName":"John","lastName":"Smith","email":"john.smith@example.com","password":"drowssaP123","phone":"+1-202-555-0192"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/user/createWithList',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '[\n {\n "username": "John78",\n "firstName": "John",\n "lastName": "Smith",\n "email": "john.smith@example.com",\n "password": "drowssaP123",\n "phone": "+1-202-555-0192"\n }\n]'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]")
val request = Request.Builder()
.url("{{baseUrl}}/user/createWithList")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/user/createWithList',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify([
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
]));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/user/createWithList',
headers: {'content-type': 'application/json'},
body: [
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
],
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/user/createWithList');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send([
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/user/createWithList',
headers: {'content-type': 'application/json'},
data: [
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/user/createWithList';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"username":"John78","firstName":"John","lastName":"Smith","email":"john.smith@example.com","password":"drowssaP123","phone":"+1-202-555-0192"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @[ @{ @"username": @"John78", @"firstName": @"John", @"lastName": @"Smith", @"email": @"john.smith@example.com", @"password": @"drowssaP123", @"phone": @"+1-202-555-0192" } ];
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/user/createWithList"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/user/createWithList" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/user/createWithList",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/user/createWithList', [
'body' => '[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/user/createWithList');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
[
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
[
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]
]));
$request->setRequestUrl('{{baseUrl}}/user/createWithList');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/user/createWithList' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/user/createWithList' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/user/createWithList", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/user/createWithList"
payload = [
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/user/createWithList"
payload <- "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/user/createWithList")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/user/createWithList') do |req|
req.body = "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/user/createWithList";
let payload = (
json!({
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
})
);
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/user/createWithList \
--header 'content-type: application/json' \
--data '[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]'
echo '[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]' | \
http POST {{baseUrl}}/user/createWithList \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '[\n {\n "username": "John78",\n "firstName": "John",\n "lastName": "Smith",\n "email": "john.smith@example.com",\n "password": "drowssaP123",\n "phone": "+1-202-555-0192"\n }\n]' \
--output-document \
- {{baseUrl}}/user/createWithList
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
[
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/user/createWithList")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Creates list of users with given input array
{{baseUrl}}/user/createWithArray
BODY json
[
{
"id": "",
"pet": "",
"username": "",
"firstName": "",
"lastName": "",
"email": "",
"password": "",
"phone": "",
"userStatus": 0
}
]
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/user/createWithArray");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/user/createWithArray" {:content-type :json
:form-params [{:username "John78"
:firstName "John"
:lastName "Smith"
:email "john.smith@example.com"
:password "drowssaP123"
:phone "+1-202-555-0192"}]})
require "http/client"
url = "{{baseUrl}}/user/createWithArray"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/user/createWithArray"),
Content = new StringContent("[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/user/createWithArray");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/user/createWithArray"
payload := strings.NewReader("[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/user/createWithArray HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 188
[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/user/createWithArray")
.setHeader("content-type", "application/json")
.setBody("[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/user/createWithArray"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]");
Request request = new Request.Builder()
.url("{{baseUrl}}/user/createWithArray")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/user/createWithArray")
.header("content-type", "application/json")
.body("[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]")
.asString();
const data = JSON.stringify([
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
]);
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/user/createWithArray');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/user/createWithArray',
headers: {'content-type': 'application/json'},
data: [
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/user/createWithArray';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"username":"John78","firstName":"John","lastName":"Smith","email":"john.smith@example.com","password":"drowssaP123","phone":"+1-202-555-0192"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/user/createWithArray',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '[\n {\n "username": "John78",\n "firstName": "John",\n "lastName": "Smith",\n "email": "john.smith@example.com",\n "password": "drowssaP123",\n "phone": "+1-202-555-0192"\n }\n]'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]")
val request = Request.Builder()
.url("{{baseUrl}}/user/createWithArray")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/user/createWithArray',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify([
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
]));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/user/createWithArray',
headers: {'content-type': 'application/json'},
body: [
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
],
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/user/createWithArray');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send([
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/user/createWithArray',
headers: {'content-type': 'application/json'},
data: [
{
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/user/createWithArray';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"username":"John78","firstName":"John","lastName":"Smith","email":"john.smith@example.com","password":"drowssaP123","phone":"+1-202-555-0192"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @[ @{ @"username": @"John78", @"firstName": @"John", @"lastName": @"Smith", @"email": @"john.smith@example.com", @"password": @"drowssaP123", @"phone": @"+1-202-555-0192" } ];
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/user/createWithArray"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/user/createWithArray" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/user/createWithArray",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/user/createWithArray', [
'body' => '[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/user/createWithArray');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
[
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
[
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]
]));
$request->setRequestUrl('{{baseUrl}}/user/createWithArray');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/user/createWithArray' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/user/createWithArray' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/user/createWithArray", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/user/createWithArray"
payload = [
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/user/createWithArray"
payload <- "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/user/createWithArray")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/user/createWithArray') do |req|
req.body = "[\n {\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n }\n]"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/user/createWithArray";
let payload = (
json!({
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
})
);
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/user/createWithArray \
--header 'content-type: application/json' \
--data '[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]'
echo '[
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
]' | \
http POST {{baseUrl}}/user/createWithArray \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '[\n {\n "username": "John78",\n "firstName": "John",\n "lastName": "Smith",\n "email": "john.smith@example.com",\n "password": "drowssaP123",\n "phone": "+1-202-555-0192"\n }\n]' \
--output-document \
- {{baseUrl}}/user/createWithArray
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
[
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/user/createWithArray")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
DELETE
Delete user
{{baseUrl}}/user/:username
QUERY PARAMS
username
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/user/:username");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/delete "{{baseUrl}}/user/:username")
require "http/client"
url = "{{baseUrl}}/user/:username"
response = HTTP::Client.delete url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Delete,
RequestUri = new Uri("{{baseUrl}}/user/:username"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/user/:username");
var request = new RestRequest("", Method.Delete);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/user/:username"
req, _ := http.NewRequest("DELETE", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
DELETE /baseUrl/user/:username HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("DELETE", "{{baseUrl}}/user/:username")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/user/:username"))
.method("DELETE", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/user/:username")
.delete(null)
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.delete("{{baseUrl}}/user/:username")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('DELETE', '{{baseUrl}}/user/:username');
xhr.send(data);
import axios from 'axios';
const options = {method: 'DELETE', url: '{{baseUrl}}/user/:username'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/user/:username';
const options = {method: 'DELETE'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/user/:username',
method: 'DELETE',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/user/:username")
.delete(null)
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'DELETE',
hostname: 'example.com',
port: null,
path: '/baseUrl/user/:username',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'DELETE', url: '{{baseUrl}}/user/:username'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('DELETE', '{{baseUrl}}/user/:username');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'DELETE', url: '{{baseUrl}}/user/:username'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/user/:username';
const options = {method: 'DELETE'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/user/:username"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"DELETE"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/user/:username" in
Client.call `DELETE uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/user/:username",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('DELETE', '{{baseUrl}}/user/:username');
echo $response->getBody();
setUrl('{{baseUrl}}/user/:username');
$request->setMethod(HTTP_METH_DELETE);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/user/:username');
$request->setRequestMethod('DELETE');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/user/:username' -Method DELETE
$response = Invoke-RestMethod -Uri '{{baseUrl}}/user/:username' -Method DELETE
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("DELETE", "/baseUrl/user/:username")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/user/:username"
response = requests.delete(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/user/:username"
response <- VERB("DELETE", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/user/:username")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.delete('/baseUrl/user/:username') do |req|
end
puts response.status
puts response.body
use std::str::FromStr;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/user/:username";
let client = reqwest::Client::new();
let response = client.request(reqwest::Method::from_str("DELETE").unwrap(), url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request DELETE \
--url {{baseUrl}}/user/:username
http DELETE {{baseUrl}}/user/:username
wget --quiet \
--method DELETE \
--output-document \
- {{baseUrl}}/user/:username
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/user/:username")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "DELETE"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
GET
Get user by user name
{{baseUrl}}/user/:username
QUERY PARAMS
username
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/user/:username");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/user/:username")
require "http/client"
url = "{{baseUrl}}/user/:username"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/user/:username"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/user/:username");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/user/:username"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/user/:username HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/user/:username")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/user/:username"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/user/:username")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/user/:username")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/user/:username');
xhr.send(data);
import axios from 'axios';
const options = {method: 'GET', url: '{{baseUrl}}/user/:username'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/user/:username';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/user/:username',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/user/:username")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/user/:username',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'GET', url: '{{baseUrl}}/user/:username'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/user/:username');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'GET', url: '{{baseUrl}}/user/:username'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/user/:username';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/user/:username"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/user/:username" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/user/:username",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/user/:username');
echo $response->getBody();
setUrl('{{baseUrl}}/user/:username');
$request->setMethod(HTTP_METH_GET);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/user/:username');
$request->setRequestMethod('GET');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/user/:username' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/user/:username' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/user/:username")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/user/:username"
response = requests.get(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/user/:username"
response <- VERB("GET", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/user/:username")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/user/:username') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/user/:username";
let client = reqwest::Client::new();
let response = client.get(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/user/:username
http GET {{baseUrl}}/user/:username
wget --quiet \
--method GET \
--output-document \
- {{baseUrl}}/user/:username
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/user/:username")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
RESPONSE HEADERS
Content-Type
application/xml
RESPONSE BODY xml
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
GET
Logs out current logged in user session
{{baseUrl}}/user/logout
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/user/logout");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/user/logout")
require "http/client"
url = "{{baseUrl}}/user/logout"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/user/logout"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/user/logout");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/user/logout"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/user/logout HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/user/logout")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/user/logout"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/user/logout")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/user/logout")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/user/logout');
xhr.send(data);
import axios from 'axios';
const options = {method: 'GET', url: '{{baseUrl}}/user/logout'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/user/logout';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/user/logout',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/user/logout")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/user/logout',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'GET', url: '{{baseUrl}}/user/logout'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/user/logout');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'GET', url: '{{baseUrl}}/user/logout'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/user/logout';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/user/logout"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/user/logout" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/user/logout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/user/logout');
echo $response->getBody();
setUrl('{{baseUrl}}/user/logout');
$request->setMethod(HTTP_METH_GET);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/user/logout');
$request->setRequestMethod('GET');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/user/logout' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/user/logout' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/user/logout")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/user/logout"
response = requests.get(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/user/logout"
response <- VERB("GET", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/user/logout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/user/logout') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/user/logout";
let client = reqwest::Client::new();
let response = client.get(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/user/logout
http GET {{baseUrl}}/user/logout
wget --quiet \
--method GET \
--output-document \
- {{baseUrl}}/user/logout
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/user/logout")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
GET
Logs user into the system
{{baseUrl}}/user/login
QUERY PARAMS
username
password
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/user/login?username=&password=");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/user/login" {:query-params {:username ""
:password ""}})
require "http/client"
url = "{{baseUrl}}/user/login?username=&password="
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/user/login?username=&password="),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/user/login?username=&password=");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/user/login?username=&password="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/user/login?username=&password= HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/user/login?username=&password=")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/user/login?username=&password="))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/user/login?username=&password=")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/user/login?username=&password=")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/user/login?username=&password=');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'GET',
url: '{{baseUrl}}/user/login',
params: {username: '', password: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/user/login?username=&password=';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/user/login?username=&password=',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/user/login?username=&password=")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/user/login?username=&password=',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'GET',
url: '{{baseUrl}}/user/login',
qs: {username: '', password: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/user/login');
req.query({
username: '',
password: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'GET',
url: '{{baseUrl}}/user/login',
params: {username: '', password: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/user/login?username=&password=';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/user/login?username=&password="]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/user/login?username=&password=" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/user/login?username=&password=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/user/login?username=&password=');
echo $response->getBody();
setUrl('{{baseUrl}}/user/login');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData([
'username' => '',
'password' => ''
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/user/login');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString([
'username' => '',
'password' => ''
]));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/user/login?username=&password=' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/user/login?username=&password=' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/user/login?username=&password=")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/user/login"
querystring = {"username":"","password":""}
response = requests.get(url, params=querystring)
print(response.json())
library(httr)
url <- "{{baseUrl}}/user/login"
queryString <- list(
username = "",
password = ""
)
response <- VERB("GET", url, query = queryString, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/user/login?username=&password=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/user/login') do |req|
req.params['username'] = ''
req.params['password'] = ''
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/user/login";
let querystring = [
("username", ""),
("password", ""),
];
let client = reqwest::Client::new();
let response = client.get(url)
.query(&querystring)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url '{{baseUrl}}/user/login?username=&password='
http GET '{{baseUrl}}/user/login?username=&password='
wget --quiet \
--method GET \
--output-document \
- '{{baseUrl}}/user/login?username=&password='
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/user/login?username=&password=")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
OK
RESPONSE HEADERS
Content-Type
application/xml
RESPONSE BODY xml
OK
RESPONSE HEADERS
Content-Type
text/plain
RESPONSE BODY text
OK
PUT
Updated user
{{baseUrl}}/user/:username
QUERY PARAMS
username
BODY json
{
"id": "",
"pet": "",
"username": "",
"firstName": "",
"lastName": "",
"email": "",
"password": "",
"phone": "",
"userStatus": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/user/:username");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/put "{{baseUrl}}/user/:username" {:content-type :json
:form-params {:username "John78"
:firstName "John"
:lastName "Smith"
:email "john.smith@example.com"
:password "drowssaP123"
:phone "+1-202-555-0192"}})
require "http/client"
url = "{{baseUrl}}/user/:username"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"
response = HTTP::Client.put url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Put,
RequestUri = new Uri("{{baseUrl}}/user/:username"),
Content = new StringContent("{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/user/:username");
var request = new RestRequest("", Method.Put);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/user/:username"
payload := strings.NewReader("{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
PUT /baseUrl/user/:username HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 168
{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("PUT", "{{baseUrl}}/user/:username")
.setHeader("content-type", "application/json")
.setBody("{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/user/:username"))
.header("content-type", "application/json")
.method("PUT", HttpRequest.BodyPublishers.ofString("{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/user/:username")
.put(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.put("{{baseUrl}}/user/:username")
.header("content-type", "application/json")
.body("{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}")
.asString();
const data = JSON.stringify({
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('PUT', '{{baseUrl}}/user/:username');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'PUT',
url: '{{baseUrl}}/user/:username',
headers: {'content-type': 'application/json'},
data: {
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/user/:username';
const options = {
method: 'PUT',
headers: {'content-type': 'application/json'},
body: '{"username":"John78","firstName":"John","lastName":"Smith","email":"john.smith@example.com","password":"drowssaP123","phone":"+1-202-555-0192"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/user/:username',
method: 'PUT',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "username": "John78",\n "firstName": "John",\n "lastName": "Smith",\n "email": "john.smith@example.com",\n "password": "drowssaP123",\n "phone": "+1-202-555-0192"\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/user/:username")
.put(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'PUT',
hostname: 'example.com',
port: null,
path: '/baseUrl/user/:username',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}));
req.end();
const request = require('request');
const options = {
method: 'PUT',
url: '{{baseUrl}}/user/:username',
headers: {'content-type': 'application/json'},
body: {
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('PUT', '{{baseUrl}}/user/:username');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'PUT',
url: '{{baseUrl}}/user/:username',
headers: {'content-type': 'application/json'},
data: {
username: 'John78',
firstName: 'John',
lastName: 'Smith',
email: 'john.smith@example.com',
password: 'drowssaP123',
phone: '+1-202-555-0192'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/user/:username';
const options = {
method: 'PUT',
headers: {'content-type': 'application/json'},
body: '{"username":"John78","firstName":"John","lastName":"Smith","email":"john.smith@example.com","password":"drowssaP123","phone":"+1-202-555-0192"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"username": @"John78",
@"firstName": @"John",
@"lastName": @"Smith",
@"email": @"john.smith@example.com",
@"password": @"drowssaP123",
@"phone": @"+1-202-555-0192" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/user/:username"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"PUT"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/user/:username" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}" in
Client.call ~headers ~body `PUT uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/user/:username",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('PUT', '{{baseUrl}}/user/:username', [
'body' => '{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/user/:username');
$request->setMethod(HTTP_METH_PUT);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'username' => 'John78',
'firstName' => 'John',
'lastName' => 'Smith',
'email' => 'john.smith@example.com',
'password' => 'drowssaP123',
'phone' => '+1-202-555-0192'
]));
$request->setRequestUrl('{{baseUrl}}/user/:username');
$request->setRequestMethod('PUT');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/user/:username' -Method PUT -Headers $headers -ContentType 'application/json' -Body '{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/user/:username' -Method PUT -Headers $headers -ContentType 'application/json' -Body '{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"
headers = { 'content-type': "application/json" }
conn.request("PUT", "/baseUrl/user/:username", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/user/:username"
payload = {
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}
headers = {"content-type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/user/:username"
payload <- "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"
encode <- "json"
response <- VERB("PUT", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/user/:username")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.put('/baseUrl/user/:username') do |req|
req.body = "{\n \"username\": \"John78\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"john.smith@example.com\",\n \"password\": \"drowssaP123\",\n \"phone\": \"+1-202-555-0192\"\n}"
end
puts response.status
puts response.body
use std::str::FromStr;
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/user/:username";
let payload = json!({
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.request(reqwest::Method::from_str("PUT").unwrap(), url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request PUT \
--url {{baseUrl}}/user/:username \
--header 'content-type: application/json' \
--data '{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}'
echo '{
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
}' | \
http PUT {{baseUrl}}/user/:username \
content-type:application/json
wget --quiet \
--method PUT \
--header 'content-type: application/json' \
--body-data '{\n "username": "John78",\n "firstName": "John",\n "lastName": "Smith",\n "email": "john.smith@example.com",\n "password": "drowssaP123",\n "phone": "+1-202-555-0192"\n}' \
--output-document \
- {{baseUrl}}/user/:username
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"password": "drowssaP123",
"phone": "+1-202-555-0192"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/user/:username")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()