Push OpenAPI document to Git
curl --request PUT \
--url https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"push": {
"outOfSyncPolicy": "abort"
}
}
'import requests
url = "https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push"
payload = { "push": { "outOfSyncPolicy": "abort" } }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({push: {outOfSyncPolicy: 'abort'}})
};
fetch('https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push",
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([
'push' => [
'outOfSyncPolicy' => 'abort'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push"
payload := strings.NewReader("{\n \"push\": {\n \"outOfSyncPolicy\": \"abort\"\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"push\": {\n \"outOfSyncPolicy\": \"abort\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"push\": {\n \"outOfSyncPolicy\": \"abort\"\n }\n}"
response = http.request(request)
puts response.read_body{
"job": {
"id": "5947aff3-947b-4dfb-90f5-d324684e97db",
"jobType": "open-api-git-pull",
"status": "ERROR",
"started": "2024-09-05T10:20:46.143759190Z",
"links": {
"self": "/v1/mock-apis/0ozge/__admin/etc/jobs/5947aff3-947b-4dfb-90f5-d324684e97db"
},
"finished": "2024-09-05T10:20:46.200386224Z",
"elapsed": "PT0.056627034S",
"outcome": {
"errorCode": "NO_LOCAL_HEAD",
"errors": [
{
"code": 112,
"title": "No previous pull",
"detail": "This is the first time pulling from Git."
}
]
}
}
}OpenAPI
Push OpenAPI document to Git
PUT
/
v1
/
mock-apis
/
{mockApiId}
/
open-api
/
push
Push OpenAPI document to Git
curl --request PUT \
--url https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"push": {
"outOfSyncPolicy": "abort"
}
}
'import requests
url = "https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push"
payload = { "push": { "outOfSyncPolicy": "abort" } }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({push: {outOfSyncPolicy: 'abort'}})
};
fetch('https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push",
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([
'push' => [
'outOfSyncPolicy' => 'abort'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push"
payload := strings.NewReader("{\n \"push\": {\n \"outOfSyncPolicy\": \"abort\"\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"push\": {\n \"outOfSyncPolicy\": \"abort\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/open-api/push")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"push\": {\n \"outOfSyncPolicy\": \"abort\"\n }\n}"
response = http.request(request)
puts response.read_body{
"job": {
"id": "5947aff3-947b-4dfb-90f5-d324684e97db",
"jobType": "open-api-git-pull",
"status": "ERROR",
"started": "2024-09-05T10:20:46.143759190Z",
"links": {
"self": "/v1/mock-apis/0ozge/__admin/etc/jobs/5947aff3-947b-4dfb-90f5-d324684e97db"
},
"finished": "2024-09-05T10:20:46.200386224Z",
"elapsed": "PT0.056627034S",
"outcome": {
"errorCode": "NO_LOCAL_HEAD",
"errors": [
{
"code": 112,
"title": "No previous pull",
"detail": "This is the first time pulling from Git."
}
]
}
}
}Path Parameters
The ID of the Mock API
Required string length:
5 - 10Example:
"jjl8y"
Body
application/json
Show child attributes
Show child attributes
Response
202 - application/json
Successfully initiated push job
Show child attributes
Show child attributes
⌘I