ERROR!
------------------- GenerateCode ----------------------
ImpliedContentType: application/x-www-form-urlencoded
---- 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;
new HttpRequest req;
call req.AddParam("grant_type","client_credentials");
call req.AddParam("scope","InvoicingAPI");
call req.AddHeader("client_id","{{clientId}}");
call req.AddHeader("grant_type","client_credentials");
call req.AddHeader("onbehalfof","100015840");
call req.AddHeader("client_secret","{{clientSecret}}");
new HttpResponse resp;
req.HttpVerb = "POST";
req.ContentType = "application/x-www-form-urlencoded";
success = http.PostUrlEncoded("https://{{apiBaseUrl}}/connect/token", req,resp);
if (success == ckfalse) {
println http.LastErrorText;
return;
}
println resp.StatusCode;
println resp.BodyStr;
---- end chilkat script ----
swift3 / LHDN MyInvois SDK / Login as Intermediary System
Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
let req = CkoHttpRequest()!
req.addParam("grant_type", value: "client_credentials")
req.addParam("scope", value: "InvoicingAPI")
req.addHeader("client_id", value: "{{clientId}}")
req.addHeader("grant_type", value: "client_credentials")
req.addHeader("onbehalfof", value: "100015840")
req.addHeader("client_secret", value: "{{clientSecret}}")
let resp = CkoHttpResponse()!
req.httpVerb = "POST"
req.contentType = "application/x-www-form-urlencoded"
ERROR: Assignment type mismatch. ExpressionType=HttpResponse, atgType=ckbool
if success == false {
print("\(http.lastErrorText!)")
return
}
print("\(resp.statusCode.intValue)")
print("\(resp.bodyStr!)")
}
Curl Command
curl -X POST
-H "client_id: {{clientId}}"
-H "client_secret: {{clientSecret}}"
-H "onbehalfof: 100015840"
-H "grant_type: client_credentials"
--data-urlencode 'grant_type=client_credentials'
--data-urlencode 'scope=InvoicingAPI'
https://{{apiBaseUrl}}/connect/token
Postman Collection Item JSON
{
"name": "Login as Intermediary System",
"request": {
"method": "POST",
"header": [
{
"key": "client_id",
"value": "{{clientId}}",
"type": "text",
"uuid": "df451b49-4e2b-4868-a180-1d01df266117"
},
{
"key": "client_secret",
"value": "{{clientSecret}}",
"type": "text",
"uuid": "c693de12-7723-4be2-aec1-00c1cdc7a797"
},
{
"key": "onbehalfof",
"value": "100015840",
"type": "text",
"uuid": "d55cb4b6-59f8-4f19-95a2-db6780b8152d"
},
{
"key": "grant_type",
"value": "client_credentials",
"type": "text",
"uuid": "7386ca83-cce5-4b62-bcb0-06e464a3b67f"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "grant_type",
"value": "client_credentials",
"type": "text"
},
{
"key": "scope",
"value": "InvoicingAPI",
"type": "text"
}
]
},
"url": {
"raw": "https://{{apiBaseUrl}}/connect/token",
"protocol": "https",
"host": [
"{{apiBaseUrl}}"
],
"path": [
"connect",
"token"
]
}
},
"response": [
]
}