ERROR!
------------------- GenerateCode ----------------------
ImpliedContentType: application/x-www-form-urlencoded
explicitContentType: 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");
new JsonObject jsonParam2;
call req.AddParam("client_id",jsonParam2.Emit());
new JsonObject jsonParam3;
call req.AddParam("client_secret",jsonParam3.Emit());
call req.AddParam("scope","pc pcapi");
new HttpResponse resp;
req.HttpVerb = "POST";
req.ContentType = "application/x-www-form-urlencoded";
success = http.PostUrlEncoded("https://domain.com/", req,resp);
if (success == ckfalse) {
println http.LastErrorText;
return;
}
println resp.StatusCode;
println resp.BodyStr;
---- end chilkat script ----
Back to Collection Items
<?php
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$http = new COM("Chilkat.Http");
$req = new COM("Chilkat.HttpRequest");
$req->AddParam('grant_type','client_credentials');
$jsonParam2 = new COM("Chilkat.JsonObject");
$req->AddParam('client_id',$jsonParam2->emit());
$jsonParam3 = new COM("Chilkat.JsonObject");
$req->AddParam('client_secret',$jsonParam3->emit());
$req->AddParam('scope','pc pcapi');
$resp = new COM("Chilkat.HttpResponse");
$req->HttpVerb = 'POST';
$req->ContentType = 'application/x-www-form-urlencoded';
ERROR: Assignment type mismatch. ExpressionType=HttpResponse, atgType=ckbool
if ($success == 0) {
print $http->LastErrorText . "\n";
exit;
}
print $resp->StatusCode . "\n";
print $resp->BodyStr . "\n";
?>
Curl Command
curl -X POST
-H "Content-Type: application/x-www-form-urlencoded"
--data-urlencode 'grant_type=client_credentials'
--data-urlencode 'client_id={{partner_client_id}}'
--data-urlencode 'client_secret={{partner_client_secret}}'
--data-urlencode 'scope=pc pcapi'
https://domain.com/
Postman Collection Item JSON
{
"name": "[Partner] Create Partner Authentication Token",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"// Extract oAuth Token from response body",
"var jsonData = JSON.parse(responseBody);",
"var partnerToken = jsonData.access_token;",
"",
"// Set to an environment variable",
"postman.setEnvironmentVariable(\"partner_token\", partnerToken);"
]
}
}
],
"_postman_id": "6f420d0f-ef65-40dc-a870-e21ff2522ccf",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "grant_type",
"value": "client_credentials",
"type": "text"
},
{
"key": "client_id",
"value": "{{partner_client_id}}",
"type": "text"
},
{
"key": "client_secret",
"value": "{{partner_client_secret}}",
"type": "text"
},
{
"key": "scope",
"value": "pc pcapi",
"type": "text"
}
]
},
"url": "{{api_host}}/oauth2/v1/token"
},
"response": [
]
}