ERROR!
------------------- GenerateCode ----------------------
ImpliedContentType: application/json
explicitContentType: application/json
---- begin chilkat script ----
// This example assumes the Chilkat API to have been previously unlocked.
// See {{-global_unlock:::Global Unlock Sample-}} for sample code.
new Http http;
ckbool success;
// Use this online tool to generate code from sample JSON: {{.https://tools.chilkat.io/jsonCreate|||Generate Code to Create JSON.}}
// The following JSON is sent in the request body.
// {
// "url": "<string>",
// "content_type": "json",
// "secret": "<string>",
// "events": [
// "position.update",
// "document.create"
// ],
// "description": "<string>",
// "id": "<long>",
// "is_active": false,
// "last_response": {
// "date": "<dateTime>",
// "code": "<integer>",
// "response": "<string>"
// }
// }
new JsonObject json;
ignore = json.UpdateString("url","<string>");
ignore = json.UpdateString("content_type","json");
ignore = json.UpdateString("secret","<string>");
ignore = json.UpdateString("events[0]","position.update");
ignore = json.UpdateString("events[1]","document.create");
ignore = json.UpdateString("description","<string>");
ignore = json.UpdateString("id","<long>");
ignore = json.UpdateBool("is_active",ckfalse);
ignore = json.UpdateString("last_response.date","<dateTime>");
ignore = json.UpdateString("last_response.code","<integer>");
ignore = json.UpdateString("last_response.response","<string>");
call http.SetRequestHeader("Content-Type","application/json");
call http.SetRequestHeader("Authorization","{{apiKey}}");
call http.SetRequestHeader("Accept","application/json");
new StringBuilder sbRequestBody;
call json.EmitSb(sbRequestBody);
HttpResponse resp = http.PTextSb("PUT","https://api.easybill.de/rest/v1/webhooks/:id",sbRequestBody,"utf-8","application/json",ckfalse,ckfalse);
if (http.LastMethodSuccess == ckfalse) {
println http.LastErrorText;
return;
}
new StringBuilder sbResponseBody;
ignore = resp.GetBodySb(sbResponseBody);
new JsonObject jResp;
call jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = ckfalse;
println "Response Body:";
println jResp.Emit();
int respStatusCode = resp.StatusCode;
println "Response Status Code = ",respStatusCode;
if (respStatusCode >= 400) {
println "Response Header:";
println resp.Header;
println "Failed.";
delete resp;
return;
}
delete resp;
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "url": "<string>",
// "content_type": "json",
// "secret": "<string>",
// "events": [
// "position.update",
// "document.create"
// ],
// "description": "<string>",
// "id": "<long>",
// "is_active": false,
// "last_response": {
// "date": "<dateTime>",
// "code": "<integer>",
// "response": "<string>"
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: {{.https://tools.chilkat.io/jsonParse|||Generate JSON Parsing Code.}}
#ifdef IS_C_CPP
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
#undef IS_C_CPP
string strVal;
string url = jResp.StringOf("url");
string content_type = jResp.StringOf("content_type");
string secret = jResp.StringOf("secret");
string description = jResp.StringOf("description");
string id = jResp.StringOf("id");
ckbool is_active = jResp.BoolOf("is_active");
string Date = jResp.StringOf("last_response.date");
string Code = jResp.StringOf("last_response.code");
string Response = jResp.StringOf("last_response.response");
int i = 0;
int count_i = jResp.SizeOfArray("events");
while i < count_i {
jResp.I = i;
strVal = jResp.StringOf("events[i]");
i = i + 1;
}
---- end chilkat script ----
Back to Collection Items
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http")
set http = Server.CreateObject("Chilkat.Http")
' Use this online tool to generate code from sample JSON: Generate Code to Create JSON
' The following JSON is sent in the request body.
' {
' "url": "<string>",
' "content_type": "json",
' "secret": "<string>",
' "events": [
' "position.update",
' "document.create"
' ],
' "description": "<string>",
' "id": "<long>",
' "is_active": false,
' "last_response": {
' "date": "<dateTime>",
' "code": "<integer>",
' "response": "<string>"
' }
' }
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set json = Server.CreateObject("Chilkat.JsonObject")
success = json.UpdateString("url","<string>")
success = json.UpdateString("content_type","json")
success = json.UpdateString("secret","<string>")
success = json.UpdateString("events[0]","position.update")
success = json.UpdateString("events[1]","document.create")
success = json.UpdateString("description","<string>")
success = json.UpdateString("id","<long>")
success = json.UpdateBool("is_active",0)
success = json.UpdateString("last_response.date","<dateTime>")
success = json.UpdateString("last_response.code","<integer>")
success = json.UpdateString("last_response.response","<string>")
http.SetRequestHeader "Content-Type","application/json"
http.SetRequestHeader "Authorization","{{apiKey}}"
http.SetRequestHeader "Accept","application/json"
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbRequestBody = Server.CreateObject("Chilkat.StringBuilder")
success = json.EmitSb(sbRequestBody)
' resp is a Chilkat.HttpResponse
Set resp = http.PTextSb("PUT","https://api.easybill.de/rest/v1/webhooks/:id",sbRequestBody,"utf-8","application/json",0,0)
If (http.LastMethodSuccess = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
Response.End
End If
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbResponseBody = Server.CreateObject("Chilkat.StringBuilder")
success = resp.GetBodySb(sbResponseBody)
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jResp = Server.CreateObject("Chilkat.JsonObject")
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0
Response.Write "<pre>" & Server.HTMLEncode( "Response Body:") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( jResp.Emit()) & "</pre>"
respStatusCode = resp.StatusCode
Response.Write "<pre>" & Server.HTMLEncode( "Response Status Code = " & respStatusCode) & "</pre>"
If (respStatusCode >= 400) Then
Response.Write "<pre>" & Server.HTMLEncode( "Response Header:") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( resp.Header) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Failed.") & "</pre>"
Response.End
End If
' Sample JSON response:
' (Sample code for parsing the JSON response is shown below)
' {
' "url": "<string>",
' "content_type": "json",
' "secret": "<string>",
' "events": [
' "position.update",
' "document.create"
' ],
' "description": "<string>",
' "id": "<long>",
' "is_active": false,
' "last_response": {
' "date": "<dateTime>",
' "code": "<integer>",
' "response": "<string>"
' }
' }
' Sample code for parsing the JSON response...
' Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
url = jResp.StringOf("url")
content_type = jResp.StringOf("content_type")
secret = jResp.StringOf("secret")
description = jResp.StringOf("description")
id = jResp.StringOf("id")
is_active = jResp.BoolOf("is_active")
Date = jResp.StringOf("last_response.date")
Code = jResp.StringOf("last_response.code")
ERROR: ASP example cannot use request or response as a variable name.
i = 0
count_i = jResp.SizeOfArray("events")
Do While i < count_i
jResp.I = i
strVal = jResp.StringOf("events[i]")
i = i + 1
Loop
%>
</body>
</html>
Curl Command
curl -X PUT
-H "Authorization: {{apiKey}}"
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"url": "<string>",
"content_type": "json",
"secret": "<string>",
"events": [
"position.update",
"document.create"
],
"description": "<string>",
"id": "<long>",
"is_active": false,
"last_response": {
"date": "<dateTime>",
"code": "<integer>",
"response": "<string>"
}
}'
https://api.easybill.de/rest/v1/webhooks/:id
Postman Collection Item JSON
{
"name": "Update WebHook",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"url\": \"<string>\",\n \"content_type\": \"json\",\n \"secret\": \"<string>\",\n \"events\": [\n \"position.update\",\n \"document.create\"\n ],\n \"description\": \"<string>\",\n \"id\": \"<long>\",\n \"is_active\": false,\n \"last_response\": {\n \"date\": \"<dateTime>\",\n \"code\": \"<integer>\",\n \"response\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/webhooks/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"webhooks",
":id"
],
"variable": [
{
"key": "id",
"value": "<long>",
"description": "(Required) ID of WebHook"
}
]
}
},
"response": [
{
"name": "Successful operation",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"url\": \"<string>\",\n \"content_type\": \"json\",\n \"secret\": \"<string>\",\n \"events\": [\n \"position.update\",\n \"document.create\"\n ],\n \"description\": \"<string>\",\n \"id\": \"<long>\",\n \"is_active\": false,\n \"last_response\": {\n \"date\": \"<dateTime>\",\n \"code\": \"<integer>\",\n \"response\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/webhooks/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"webhooks",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"url\": \"<string>\",\n \"content_type\": \"json\",\n \"secret\": \"<string>\",\n \"events\": [\n \"position.update\",\n \"document.create\"\n ],\n \"description\": \"<string>\",\n \"id\": \"<long>\",\n \"is_active\": false,\n \"last_response\": {\n \"date\": \"<dateTime>\",\n \"code\": \"<integer>\",\n \"response\": \"<string>\"\n }\n}"
},
{
"name": "Not found",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"url\": \"<string>\",\n \"content_type\": \"json\",\n \"secret\": \"<string>\",\n \"events\": [\n \"position.update\",\n \"document.create\"\n ],\n \"description\": \"<string>\",\n \"id\": \"<long>\",\n \"is_active\": false,\n \"last_response\": {\n \"date\": \"<dateTime>\",\n \"code\": \"<integer>\",\n \"response\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/webhooks/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"webhooks",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
},
{
"name": "Too Many Requests",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"url\": \"<string>\",\n \"content_type\": \"json\",\n \"secret\": \"<string>\",\n \"events\": [\n \"position.update\",\n \"document.create\"\n ],\n \"description\": \"<string>\",\n \"id\": \"<long>\",\n \"is_active\": false,\n \"last_response\": {\n \"date\": \"<dateTime>\",\n \"code\": \"<integer>\",\n \"response\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/webhooks/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"webhooks",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
}
]
}