I'm using the following endpoint to add an attachment to an envelope:
PUT /v2.1/accounts/{accountId}/envelopes/{envelopeId}/attachments
Apparently the request goes well because I get this return:
"attachments" => array:2 [
0 => array:4 [
"attachmentId" => "656A658D-AD83-438C-B58D-86738486349C"
"attachmentType" => "png"
"name" => "asdas"
"accessControl" => "SenderAndAllRecipients"
]
]
But nothing appears to the signers on the view. Where the signers can download or visualize the attachments that were added through the api?
UPDATE
The method to send the attachments:
public function addAttachments($saleContract, $envelopeId)
{
$attachments = array();
foreach ($saleContract->document as $document){
array_push($attachments, [
'accessControl' => 'senderAndAllRecipients',
'attachmentId' => $document->id,
'attachmentType' => \File::extension($document->storage_file_name),
'data' => base64_encode(Storage::disk('sienge')->get($document->storage_file_name)),
'name' => $document->file_name,
]);
}
Docusign::addEnvelopeAttachments($envelopeId, $attachments);
}
These are Envelope API Attachments and can be access only via API. When you add these attachments via API, then you can access via API only and will not be available on the Signing screen.
These are like metadata available in an envelope which should not be shown on the Signing screen, and can be accessed via API only. Dev Doc explains how to read these API attachments
Related
Is it possible to get data from new Google Analytics (GA4) accounts through API V4? It always returns the following error message:
{ "error": { "code": 403, "message": "User does not have sufficient permissions for this profile.", "errors": [ { "message": "User does not have sufficient permissions for this profile.", "domain": "global", "reason": "forbidden" } ], "status": "PERMISSION_DENIED" } }
I can do it perfectly on UA accounts.
Is there any API (web server request - OAuth) specific to this new account type?
property id
Here is the code used (PHP):
require_once __DIR__ . '/vendor/autoload.php';
session_start();
$client = new Google_Client();
$client->setAuthConfig(__DIR__ . '/FILE.json');
$client->addScope(Google_Service_Analytics::ANALYTICS_READONLY);
$client->setAccessToken($_SESSION['access_token']);
$analytics = new Google_Service_AnalyticsReporting($client);
$response = getReport($analytics);
printResults($response);
function getReport($analytics){
$dateRange = new Google_Service_AnalyticsReporting_DateRange();
$dateRange->setStartDate("7daysAgo");
$dateRange->setEndDate("today");
$sessions = new Google_Service_AnalyticsReporting_Metric();
$sessions->setExpression("name");
$sessions->setAlias("sessions");
$request = new Google_Service_AnalyticsReporting_ReportRequest();
$request->setViewId('307566943');
$request->setDateRanges($dateRange);
$request->setMetrics(array($sessions));
$body = new Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests( array( $request) );
return $analytics->reports->batchGet( $body );
}
User does not have sufficient permissions for this profile
Means that the user you have authenticated your application with. Does not have permission to access the Google analytics view you are trying to extract data from.
The issue can also be caused if you are trying to use the Google analytics reporting api with a Google analytics GA4 account. As GA4 property id are not the same as UA view ids. The system gets confused and assumes you just dont access.
The solution is to authenticate the app with a user that has access to that view or grant the user access. And to check that you are using the correct api for the type of google analytics you are trying to access.
UA vs GA4
Also remember that to extract date from a GA4 account you need to use the Google analytics data api. If you have extracted data from UA accounts you have been using the Google analytics reporting api. These are two completely diffrent APIs with diffrent methods.
Google analytics data api quick start
require 'vendor/autoload.php';
use Google\Analytics\Data\V1beta\BetaAnalyticsDataClient;
use Google\Analytics\Data\V1beta\DateRange;
use Google\Analytics\Data\V1beta\Dimension;
use Google\Analytics\Data\V1beta\Metric;
/**
* TODO(developer): Replace this variable with your Google Analytics 4
* property ID before running the sample.
*/
$property_id = 'YOUR-GA4-PROPERTY-ID';
// Using a default constructor instructs the client to use the credentials
// specified in GOOGLE_APPLICATION_CREDENTIALS environment variable.
$client = new BetaAnalyticsDataClient();
// Make an API call.
$response = $client->runReport([
'property' => 'properties/' . $property_id,
'dateRanges' => [
new DateRange([
'start_date' => '2020-03-31',
'end_date' => 'today',
]),
],
'dimensions' => [new Dimension(
[
'name' => 'city',
]
),
],
'metrics' => [new Metric(
[
'name' => 'activeUsers',
]
)
]
]);
// Print results of an API call.
print 'Report result: ' . PHP_EOL;
foreach ($response->getRows() as $row) {
print $row->getDimensionValues()[0]->getValue()
. ' ' . $row->getMetricValues()[0]->getValue() . PHP_EOL;
}
I have been trying to figure out how to automatically add recipients to a Draft email that is created using the Gmail API through their Ruby library. I can create the draft without any issues but setting the recipients is causing me troubles and I haven't been able to find any good examples showing the best way to add email specific things.
Using the Google API playground and pulling in drafts that have already been created, it looks like the structure should be something similar to what is shown below, but whenever the draft is created, there are no recipients.
#result = client.execute(
:api_method => gmail.users.drafts.create,
:parameters => {
'userId' => "me"
},
:body_object => {
'message' => {
'raw' => Base64.urlsafe_encode64('Test Email Message'),
'payload' => {
'headers' =>
[
{
'name' => "To",
'value' => "John Smith <john_smith.fake#gmail.com>"
}
]
}
}
}
)
'raw' should contain the entire (RFC822) email, complete with body and headers. Do not use the 'payload.headers' structure, that parsed format is only used for returning during message.get() presently.
so for 'raw' you'd want to Base64.urlsafe_encode64() a string like:
"To: someguy#example.com\r\nFrom: myself#example.com\r\nSubject: my subject\r\n\r\nBody goes here"
I'm using this Mailchimp 2.0 PHP wrapper:
https://github.com/drewm/mailchimp-api
To send data to my list via the Mailchimp 2.0 API.
I can get email, firstname, and lastname to send successfully from my form to mailchimp.
I set those up as required fields in mailchimp(EMAIL, FNAME, LNAME).
Here is the PHP for that:
$MailChimp = new MailChimp('xxxxxxx');
$result = $MailChimp->call('lists/subscribe', array(
'id' => 'xxxxxx',
//required fields
'email' => array( 'email' => $_POST['email']),
'merge_vars' => array('FNAME' => $_POST['fname'], 'LNAME' => $_POST['lname']),
//mailchimp options
'double_optin' => false,
'update_existing' => true,
'replace_interests' => false
));
But I also have 12 checkboxes for stuff like engine size, type, gas type, color, etc. that are optional.
How can send these to the mailchimp API? I'm hoping someone with experience with Mailchimp API could help out.
Any help would be appreciated.
Thanks!
Here is a clarification to the structure of the groupings that is not in the docs' example. I.e. you supply only the names of the groups that have been selected by the user:
"merge_vars": {
"groupings": [
{
"groups": [
"selection 3",
"selection 7"
],
"id": <group_id>// or "name": <group_name>
}
]
},
In the merge_vars array, define "groupings" which points to an array. This 'groupings' array will then consist of individual arrays that point to a particular grouping of groups. Ex. if you have a grouping of groups titled "gas type" with group options "diesel", "unleaded", etc. this level of the array points to "gas type".
THEN, you define a "groups" array inside of this array to denote membership into the actual subgroups ("diesel", "unleaded").
Here's a code example from the list subscribe MailChimp API 2.0 documentation:
"merge_vars": {
"groupings": [
{
"id": 42,
"name": "example name",
"groups": [
"..."
]
}
]
lists/subscribe: http://apidocs.mailchimp.com/api/2.0/lists/subscribe.php
My personal suggestion: create groups in the web app if you haven't already. Then, use the lists/interest-groupings method to see how the interest groups are formatted and returned to you. This gives you a sense of how to structure it in your own code.
lists/interest-groupings: http://apidocs.mailchimp.com/api/2.0/lists/interest-groupings.php
I use Mandrill plugin for Codeigniter.
I created HTML template through Mandrill account, named fess1 with merge tag FNAME, after I published it.
Example:
...
<p>
<span>Hi *|FNAME|*,<br></span>
</p>
....
Now I try to send mail from codeigniter like:
private function sendMailMandrill($owner_name,$business_name,$owner_email){
$message = array('dest_mail' => $owner_email);
$message['to'] = array(array('email' => 'mim#wefi.com'));
$mergeVars[] = array(
'rcpt' => array(array('email' => 'mim#wefi.com')),
'vars' => array(
array(
'name' => 'FNAME',
'content' => 'Fessy'
)
)
);
$message['merge'] = true;
$template_name = 'fess1';
$template_content = array( // I don't know what I need to provide here, left it empty
array(
'name' => 'example name',
'content' => 'example content'
)
);
$message['merge_vars'] = $mergeVars;
return $this->mandrill->messages_send_template($template_name, $template_content, $message);
}
The result:
I get the mail, based on fess1 template, but with the tag *|FNAME|*.
Sounds like Mandrill didn't recognize the merge tag.
I used mandrill->messages_send_template but since my template stored into Mandrill account I have no clue what I need to provide for $template_content.
So I wrote dummy info there.
Did I miss something?
Thank you,
[EDIT]
From logs this is what I send:
{
"template_name": "fess1",
"template_content": [
{
"name": "example name",
"content": "example content"
}
],
"message": {
"owner_name": "עידו",
"business_name": "פלאפל מוסקו",
"dest_mail": "maxim#wifi.com",
"to": [
{
"email": "maxim#wifi.com"
}
],
"merge": "true",
"merge_vars": [
{
"rcpt": [
{
"email": "maxim#wifi.com"
}
],
"vars": [
{
"name": "FNAME",
"content": "Fessy"
}
]
}
]
},
"key": "xxxxxxxxxxxxxxxx"
}
You can provide blank information for the template_content parameter. That parameter allows you to use mc:edit regions in your template. It is a required parameter, but a blank array will suffice if all of the content is in your template in Mandrill.
As for whether the merge_vars were recognized, the first thing we recommend is inspecting the API Logs for your account (Settings > API Logs) since that will show you the JSON that Mandrill received. You can then compare that to the expected JSON format from the Mandrill API docs: https://mandrillapp.com/api/docs/messages.JSON.html#method=send-template
It looks like your arrays may not be nested as expected. Once you view the JSON that's being generated as compared with the expected format, you can also view the PHP documentation for the Mandrill PHP client. It may not be identical to the CodeIgniter plugin, but should give you an idea of how the merge_vars parameter would be structured in PHP: https://mandrillapp.com/api/docs/messages.php.html
In mergeVars you created array instead key:value. Change it to:
'rcpt' => 'mim#wefi.com',
I am having trouble figuring out how to add a calendar to all of a domain's users' CalendarList.
So far I can successfully create the Calendar and create a domain wide ACL but I don't know how to insert the calendar into domain users' lists.
Using the ruby client API it looks something like this:
client = Google::APIClient.new
service = client.discovered_api("calendar", "v3")
calendar_response = JSON.parse(client.execute(:api_method => service.calendars.insert,
:body => JSON.dump({"summary" => "events"}),
:headers => { "Content-Type" => "application/json" }).response.body)
rule = {
"scope" => {
"type" => "domain",
"value" => domain,
},
"role" => "writer"
}
acl_result = client.execute(:api_method => service.acl.insert,
:parameters => { "calendarId" => calendar_response["id"] },
:body => JSON.dump(rule),
:headers => { "Content-Type" => "application/json" })
This all works fine. It creates the calendar and it is shared with everyone in the domain. What I can't figure out is how to explicitly added it to the users' list of Calendars.
To add to the single authed user's calendar list would look like this:
list_params = {
"calendarId" => calendar_response["id"],
"hidden" => false,
"selected" => true
}
calendar_list_result = client.execute(:api_method => service.calendar_list.insert,
:body => JSON.dump(list_params),
:headers => { "Content-Type" => "application/json" })
Questions:
If I am authenticated as a domain admin, can I create CalendarList item for all users?
If so, can it be done with a single command or do I need to make a call with every user id?
If I need to do a command for each user, how do I get the user ids?
If I am authenticated as a domain admin, can I create CalendarList item for all users?
No you can't :(.
If so, can it be done with a single command or do I need to make a call with every user id?
You have to make a call for each user id.
If I need to do a command for each user, how do I get the user ids?
To retrieve the user id you first must list all the users in the domain with the Admin SDK API, https://developers.google.com/admin-sdk/directory/v1/guides/manage-users#get_all_domain_users , then for each INSERT command in the calendar you change the user id, for the email address.