So have been playing with this for a while now.
Pretty new with SOAP to be honest.
Issue is this:
I have documentation which i have been following and i can retrieve one persons profile using the unique ID.
Now i want to receive all users in a certain pool/group/target etc.
here is what i am using:
$client = new SoapClient($pr, array('login' => $username, 'password' => $password, 'trace'=>true));
and the code is like so:
$job_info = $client->getByTargetGroup(16520);
also tried this
$job_info = $client->getByTargetGroup(16520, array('NAME','EMAIL','FIRSTNAME') );
In the documentation of the soap i get this info:
parameters type getByTargetGroup
targetgroup_id type int
pool_attribute_list - nillable; type ArrayOfString
**item** - optional, unbounded; type string
But when executed i get this error
Fatal error: Uncaught SoapFault exception: [Receiver] Maximum number of 20 active jobs exceeded for this customer
Am i using SOAP correctly? or reading the documentation incorrectly?
I am just doing this to view feedback
echo "<pre>";
print_r( $job_info);
echo "</pre>";
Image link to the documentation:
Image
Related
I am using Docusign PHP Client and trying to create and envelope and send it as email. With the current SDK, I was getting an error:
INVALID_REQUEST_BODY The request body is missing or improperly formatted. Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'API_REST.Models.v2.document[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\r\n ◀
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive t ▶
Path 'documents.documentBase64', line 1, position 31.
So I had to edit EnvelopeApi.php (line 2876) json_encode($httpBody) to make it work.
Now that it's working, I receive a response like this, however I can't change status created to sent is my problem.
EnvelopeSummary {#460 ▼
#container: array:4 [▼
"envelope_id" => "6b9ef863-2ee0-4ea6-9f7e-20b7d4f59b22"
"status" => "created"
"status_date_time" => "2018-10-03T12:30:22.8600000Z"
"uri" => "/envelopes/6b9ef863-2ee0-4ea6-9f7e-20b7d4f59b22"
]
}
My full code:
First, I authenticated and fetched my $accountId
And then creating Envelope:
$path = public_path('test.pdf');
$b64Doc = base64_encode(file_get_contents($path));
$document = new Document();
$document->setName("TEST.pdf");
$document->setFileExtension("pdf");
$document->setDocumentId(1);
$document->setDocumentBase64($b64Doc);
$sign_here = new SignHere();
$sign_here->setXPosition(25);
$sign_here->setYPosition(50);
$sign_here->setDocumentId(1);
$sign_here->setPageNumber(1);
$sign_here->setRecipientId(1);
$tabs = new Tabs();
$tabs->setSignHereTabs($sign_here);
$signers = new Signer();
$signers->setName('Test User');
$signers->setEmail('test#mailinator.com');
$signers->setRoleName('Signer');
$signers->setRecipientId(1);
$signers->setRoutingOrder(1);
$signers->setTabs($tabs);
$recipients = new Recipients();
$recipients->setSigners($signers);
$envelope_definition = new EnvelopeDefinition();
$envelope_definition->setEmailSubject('Signature Request');
$envelope_definition->setStatus("sent"); // ***
$envelope_definition->setDocuments($document);
$envelope_definition->setRecipients($recipients);
$options = new CreateEnvelopeOptions();
$options->setCdseMode(null);
$options->setMergeRolesOnDraft(null);
try {
$envelopeSummary = $envelopeApi->createEnvelope($accountId, $envelope_definition, $options);
dd($envelopeSummary);
// Also tried this:
// $envelopeApi->update($accountId, $envelopeSummary->getEnvelopeId(), json_encode(['status' => 'sent']);
} catch (ApiException $e){
dd($e->getResponseBody()->errorCode . " " . $e->getResponseBody()->message);
}
$envelope_definition->setStatus("sent"); this should trigger the email, right? But it doesn't for some reason. Also I can't see this created envelope in my Sandbox either.
You are not setting signers correctly. It must be an array of signer objects.
Here is some untested code:
# This code creates a signer, not signers
$signer = new Signer();
$signer->setName('Test User');
$signer->setEmail('test#mailinator.com');
$signer->setRoleName('Signer');
$signer->setRecipientId(1);
$signer->setRoutingOrder(1);
$signer->setTabs($tabs);
$recipients = new Recipients();
# setSigners wants an array of signer objects.
# in this case, we make an array with one element
$recipients->setSigners(array($signer));
Also, you are not creating the tabs right either. Again, it needs to be an array of the tab type.
See this example for additional ideas.
Yes, setting status to sent should make DocuSign send the envelope upon creation. The fact that the response contains "status" => "created" seems to indicate that your setting of the property ($envelope_definition->setStatus("sent");) is not actually being included as part of the request that's being issued to DocuSign.
I've compared your code with the code examples provided in GitHub for the PHP SDK, specifically, with the signatureRequestOnDocument function on that page. The only obvious difference I can see between your code and that example code is in the syntax for creating objects. For example, creating the envelope:
Your code: $envelope_definition = new EnvelopeDefinition();
PHP SDK example code: $envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition();
I don't know much about PHP, let alone about the DocuSign PHP SDK, but I'd suggest that you try to closely mimic the code examples that are part of the SDK repo on GitHub, to see if you get a different result that way.
My code work like this :
$signersArray = array();
$signer = new Signer();
$signer->set...
$signersArray[] = $signer;
$recipients->setSigners($signersArray);
If it's not working try to dump the data send from the SDK to the API and double check that the status is correct :
Go to Docusign/esign-client/src/ApiClient.php and var_dump($postData) at line 159
I want to delete an event in Vtiger Calendar using REST APIs. I'm trying the following:
POST /webservice.php HTTP/1.1
operation=delete
sessionName=sessionId // Obtained through Login Operation
id=<WEBSERVICE_ID>
but I don't know what WEBSERVICE_ID is and where to find it.
When I create an event using REST-API it returns an array with the following data:
{"subject":"Follow up Test","assigned_user_id":"49x1","date_start":"2016-06-17","time_start":"09:00:00","time_end":"18:00:00","due_date":"2016-06-17","recurringtype":"","parent_id":"","contact_id":"","taskstatus":"","eventstatus":"Planned","taskpriority":"High","sendnotification":"0","createdtime":"2016-06-23 11:18:20","modifiedtime":"2016-06-23 11:18:20","activitytype":"Event","visibility":"","duration_hours":"9","duration_minutes":"0","location":"","notime":"0","modifiedby":"49x1","created_user_id":"49x1","source":"WEBSERVICE","starred":"0","tags":"","reminder_time":"","description":"Test Description","id":"1x5748","label":"Follow up Test"}
There is an id in the array ("id":"1x5748"), but when I try to use the id as a WEBSERVICE_ID in the delete operation I'm getting the following error:
Fatal error: Uncaught exception 'Exception' with message 'Error: Id specified is incorrect'
Run this query: SELECT id, nameFROM vtiger_ws_entity
Whith this your objectTypeId is a id for module
Get the record id
concatenate 1And2 for example: EVENTS module='18' AND record id=61900, then the ID that you need is: 18x61900;
I use this code for delete entity
$params = array(
//"id" => "35789",
"id" => "18x61900",
);
$record = $client->doInvoke("delete", $params, "POST");
While using Google Cloud Compute's API in PHP, I am able to start, stop, delete instances as well as create and delete disks.
However, when trying to create an Instance, I keep getting this error
Invalid value for field 'resource.disks'
PHP Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling POST https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances: (400) Invalid value for field 'resource.disks': ''. Boot disk must be specified.' in /var/www/html/google/google-api-php-client/src/Google/Http/REST
Here is the request I am making
self::connectClient();
$computeService = new Google_Service_Compute($this->client);
if ($this->client->getAccessToken())
{
$googleNetworkInterfaceObj = new Google_Service_Compute_NetworkInterface();
$network = self::DEFAULT_NETWORK;
$googleNetworkInterfaceObj->setNetwork($network);
$diskObj = self::getDisk($instance_name);
$new_instance = new Google_Service_Compute_Instance();
$new_instance->setName($instance_name);
$new_instance->setMachineType(self::DEFAULT_MACHINE_TYPE);
$new_instance->setNetworkInterfaces(array($googleNetworkInterfaceObj));
$new_instance->setDisks(array(
"source"=>$diskObj->selfLink,
"boot"=>true,
"type"=>"PERSISTENT",
"deviceName"=>$diskObj->name,
));
$insertInstance = $computeService->instances->insert(self::DEFAULT_PROJECT,self::DEFAULT_ZONE_NAME, $new_instance);
Any help will be highly appreciated, thank you.
Ok the solution was really simple (and silly)
Instead of
$new_instance->setDisks(array(
"source"=>$diskObj->selfLink,
"boot"=>true,
"type"=>"PERSISTENT",
"deviceName"=>$diskObj->name,
));
It's supposed to be
$new_instance->setDisks(array(
array(
'source'=>self::getDisk($instance_name)->selfLink,
'boot'=>true,
'type' => "PERSISTENT",
'deviceName'=>self::getDisk($instance_name)->name,
)
));
I am trying to use the Magento API to UPDATE a product. I am getting error code #1 with the following message:<b>Fatal error</b>: Uncaught SoapFault exception: [1] Internal Error. Please see log for details.
Below is my PHP that calls the service and should update three attributes. The Magento api documentation leaves a lot to the imagination so I am stuck
$ItemNmbr = $itemData->Item->ItemNmbr;
$ItemDesc = $itemData->Item->ItemDesc;
$UnitPrce = $itemData->Item->UnitPrce;
$client = new SoapClient('http://website.com/store/api/?wsdl');
$session = $client->login('apiname', 'apipassword');
$result = $client->call($session, 'catalog_product.update', array(168, array(
'description' => $ItemDesc,
'price' => $UnitPrce,
'weight' => $Weight
)));
var_dump ($result);
I am statically setting the ProductID above for now. Any information that will help me understand what I am doing wrong would be much appreciated.
I am having a tough time and have spent like 4 hrs trying to debug this. I am new to PHP, but did not expect this to be so hard.
This is the code, i am trying to update a contact table. i tried upsert and update nothign seems to work
this is the update" version of the code.
$id = '003A000000XRVFxIAP';
$updateFields = array (
'Id' => $id,
'MailingCity' => 'New York',
'MailingState' => 'NY'
);
$sObject1 = new SObject();
//$sObject1->fields = $updateFields;
//$sObject1->MailingCity= 'New York';
$sObject1->type = 'Contact';
try{
$updateResponse = $client->update(array($sObject1),'Contact');
$myID = $updateResponse->id;
}
Strict Standards: Creating default object from empty value in C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\SforceEnterpriseClient.php on line 89 INVALID_FIELD: No such column 'fields' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. Error Info SoapFault exception: [sf:INVALID_FIELD] INVALID_FIELD: No such column 'fields' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. in C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\SforceBaseClient.php:508 Stack trace: #0 C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\SforceBaseClient.php(508): SoapClient->__call('update', Array) #1 C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\SforceBaseClient.php(508): SoapClient->update(Object(stdClass))
#2 C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\SforceEnterpriseClient.php(90): SforceBaseClient->_update(Object(stdClass))
#3 C:\xampp\htdocs\Proj1\createAccount.php(95): SforceEnterpriseClient->update(Array, 'Contact') #4 {main}
Looking at your trace you appear to be using the enterprise client and I can assume enterprise WSDL. This is strongly typed and you should be using the WSDL specific to your Salesforce org. If you are not using the WSDL downloaded from your org it will not have the correct objects and fields defined within it.
I would recommend using the partner client and partner WSDL. This is loosely typed and far more flexible. It would be easier to work with particularly if you aren't familiar with the PHP or the webservices.
The following should do your update...
$sObject1 = new stdClass();
$sObject1->type = 'Contact';
$sObject1->Id = $id;
$sObject1->fields['MailingCity'] = 'New York';
$sObject1->fields['MailingState'] = 'NY';
try
{
$updateResponse = $client->update( array( $sObject1 ) );
}
catch( Exception $exception )
{
// Do something
}
Note that the Id is a property of $sObject and not a value in the fields array. Also there is no need to specify the 'Contact' in your update call as you have it set in the type property of $sObject.
When using the Enterprise WSDL, don't create a new SObject, just create a new stdClass. See the examples in the PHP Getting Started Guide; SObjects are only for use with the partner WSDL.
I have encountered the same issue updating while using the Enterprise client. I experienced the same issue while updating a custom field on an Account object.
The issue that I had with the SObject was that it tried to update a parameter called 'fields' during the update. With the Enterprise WSDL not including that field, I used unset() to remove the 'fields' attribute from the SObject.
I appreciate this is a bit of a hacky solution, but it could come in useful for others that encounter this issue.
$sUpdateObject = new SObject();
$sUpdateObject->id = $record->Id;
$sUpdateObject->MyCustomField__c = 0;
unset($sUpdateObject->fields);
$updateResponse = $mySforceConnection->update(array($sUpdateObject), 'Account');
print_r($upsertResponse);