Help using Scribe Web API to install connectors and provision a cloud agent

I'm new to Scribe and been using a mixture of Web API Reference application and the interactive API explorer to learn. The documentation makes sense but I just can't get things to work as I would expect! Hoping somebody can help...

 

I've written a PHP/cURL application to create a new Organisation and invite a user to the new organisation - this works fine.

 

Looking at: https://dev.scribesoft.com/en/main/how/provision_child_org.htm - I now need to provision a cloud agent (I am planning on using the Salesforce Connector) and also install the connectors (Just Salesforce for now, whilst my company work on deploying a new connector to the marketplace) - according to the documentation, neither endpoint return a response, which would be fine if it actually worked!!

 

My code:

<?php
 
public function curl_request($url, $authorisation_type, $access_token, $params = [], $request_type = 'get', $content_type = 'application/json', $accept_type = 'application/json') {
$ch = curl_init();
$headers = [
"Accept: {$accept_type}",
"Content-Type: {$content_type}",
"Authorization: {$authorisation_type} {$access_token}",
];
 
$opts = [
CURLOPT_URL => $this->base_url.$url,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_HEADER => 0,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true,
];
 
if($request_type == 'get' && !empty($params)) {
$vars = http_build_query($params);
$opts[CURLOPT_URL] = "{$this->base_url}{$url}?{$vars}";
}
 
if($request_type == 'post') {
$opts[CURLOPT_POST] = 1;
 
if(!empty($params)) {
$opts[CURLOPT_POSTFIELDS] = json_encode($params);
}
}
 
if($request_type == 'delete') {
$opts[CURLOPT_CUSTOMREQUEST] = "DELETE";
$opts[CURLOPT_POSTFIELDS] = json_encode($params);
}
 
if($request_type == 'put') {
$opts[CURLOPT_CUSTOMREQUEST] = "PUT";
$opts[CURLOPT_POSTFIELDS] = json_encode($params);
}
 
$this->workbooks->log('API Call', $opts, 'info', 250000);
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
 
if ($result === false) {
curl_close($ch);
throw new Exception(curl_error($ch));
}
 
$result = json_decode($result, true);
$this->workbooks->log('API Response', $result, 'info', 250000);
 
curl_close($ch);
return $result;
}

$mp_params['filterByName'] = 'Salesforce';
$connectors = $this->curl_request('marketplace/connectors', 'Basic', $this->access, $mp_params, 'get');

$create_org = $this->curl_request('orgs', 'Basic', $this->access, $scribe_params, 'post');

//Install each of the Salesforce Connectors to the Created org
foreach($connectors as $connector) { //TODO doesn't work
$install_con = $this->curl_request("orgs/{$create_org['id']}/connectors/{$connector['adapterTypeId']}/install", 'Basic', $this->access, [], 'post');
}
 
//Provision a Cloud Agent - TODO doesn't work
$agent_creation = $this->curl_request("orgs/{$create_org['id']}/agents/provision_cloud_agent", 'Basic', $this->access, [], 'post');
sleep(3); //Wait for a bit, the agent might take a few seconds.
 
$existing_agent = $this->curl_request("orgs/{$create_org['id']}/agents", 'Basic', $this->access, [], 'get'); //TODO Doesn't return anything

?>

After running the above, I don't see any errors returned from the API. However, the connectors are not installed (there are two found on the Marketplace that match the "Salesforce" Filter. I also don't see a Cloud agent provisioned in the Scribe UI.

 

From what I can see in the reference API, my API call to Scribe is not any different. Could somebody help me spot what I'm doing wrong here please?

 

Thanks!

Jamie

(6) Answers

Login