Hi,
How to convert the following CURL code into QM code? The Chilkat C# code below can work, but the DLL is too large.
Thank you in advance for any suggestions and help.
David
CURL Code:
ChilKat C# Code:
The following code is not working. Why?
Macro Macro7
How to convert the following CURL code into QM code? The Chilkat C# code below can work, but the DLL is too large.
Thank you in advance for any suggestions and help.
David
CURL Code:
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/contents/PATH \
-d '{"message":"my commit message","committer":{"name":"Monalisa Octocat","email":"[email protected]"},"content":"bXkgbmV3IGZpbGUgY29udGVudHM="}'
ChilKat C# Code:
Add-Type -Path "C:\chilkat\ChilkatDotNet47-9.5.0-x64\ChilkatDotNet47.dll"
$rest = New-Object Chilkat.Rest
# URL: https://api.github.com/repos/OWNER/REPO/contents/PATH
$bTls = $true
$port = 443
$bAutoReconnect = $true
$success = $rest.Connect("api.github.com",$port,$bTls,$bAutoReconnect)
if ($success -ne $true) {
$("ConnectFailReason: " + $rest.ConnectFailReason)
$($rest.LastErrorText)
exit
}
# Note: The above code does not need to be repeatedly called for each REST request.
# The rest object can be setup once, and then many requests can be sent. Chilkat will automatically
# reconnect within a FullRequest* method as needed. It is only the very first connection that is explicitly made via the Connect method.
# Use this online tool to generate code from sample JSON: Generate Code to Create JSON
# The following JSON is sent in the request body
# {
# "message": "my commit message",
# "committer": {
# "name": "Monalisa Octocat",
# "email": "[email protected]"
# },
# "content": "bXkgbmV3IGZpbGUgY29udGVudHM="
# }
$json = New-Object Chilkat.JsonObject
$json.UpdateString("message","my commit message")
$json.UpdateString("committer.name","Monalisa Octocat")
$json.UpdateString("committer.email","[email protected]")
$json.UpdateString("content","bXkgbmV3IGZpbGUgY29udGVudHM=")
$rest.AddHeader("Authorization","Bearer <YOUR-TOKEN>")
$rest.AddHeader("Accept","application/vnd.github+json")
$rest.AddHeader("X-GitHub-Api-Version","2022-11-28")
$sbRequestBody = New-Object Chilkat.StringBuilder
$json.EmitSb($sbRequestBody)
$sbResponseBody = New-Object Chilkat.StringBuilder
$success = $rest.FullRequestSb("PUT","/repos/OWNER/REPO/contents/PATH",$sbRequestBody,$sbResponseBody)
if ($success -ne $true) {
$($rest.LastErrorText)
exit
}
$respStatusCode = $rest.ResponseStatusCode
$("response status code = " + $respStatusCode)
if ($respStatusCode -ge 400) {
$("Response Status Code = " + $respStatusCode)
$("Response Header:")
$($rest.ResponseHeader)
$("Response Body:")
$($sbResponseBody.GetAsString())
exit
}
The following code is not working. Why?
Macro Macro7
str url = "https://api.github.com/repos/OWNER/REPO/contents/PATH"
str headers =
F
;{{
;"Accept": "application/vnd.github+json",
;"Authorization": "Bearer <YOUR-TOKEN>",
;"X-GitHub-Api-Version": "2022-11-28"
;}
str body =
F
;{{
;;;;;"message": "my commit message",
;;;;;"committer": {{
;;;;;;;;;;;;;;;;;;;;;;;"email": "[email protected]",
;;;;;;;;;;;;;;;;;;;;;;;"name": "Monalisa Octocat"
;;;;;;;;;;;;;;;;;;;},
;;;;;"content": "bXkgbmV3IGZpbGUgY29udGVudHM="
;}
str r8 r9
Http Host.Connect(url 0 0 443)
out Host.Post("Put" body r8 headers INTERNET_FLAG_SECURE r9)
out r8
out r9