mailgun - multiple tagging using "o:tag" - mailgun

I'm trying to multi-tag emails sent from my node (meteor) app. The mailgun docs give the following curl snippet:
curl -s --user 'api:YOUR_API_KEY' \
https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages \
[...]
-F o:tag='September newsletter' \
-F o:tag='newsletters'
So how do you add these multiple tags in a normal JS object?? You can't have duplicate keys in the object, so I tried an array:
const params = {to, from, subject, html, "o:tag": ["reminders, "reminder wk1"]}
HTTP.post("https://api.mailgun.net/v3/myDomain/messages", {params, auth});
But the array seems to be joined so the result is only one tag comes up as a single string "reminders, reminder wk1".
So any ideas on adding multiple tags like this? Or do I have to take another approach?

This is an old question, but as i was asking myself the same one here is the answer :
https://www.npmjs.com/package/mailgun-js is now deprecated.
It's recommended to use : https://www.npmjs.com/package/mailgun.js
Its not specified in the documentation but you can pass multiple tags :
const params = {to, from, subject, html, "o:tag": ['tag1', 'tag2']}

Response from Mailgun tech support: just use the Mailgun NPM package, which supports multiple tags.
https://www.npmjs.com/package/mailgun-js
(Bizarrely, Mailgun don't monitor questions with the Mailgun tag, hence answering my own question)

Related

AWS Kendra get _document_body attribute

I'm trying to query aws kendra but I need to have the document_body in the ResultItem response.
I tried with the RequestedDocumentAttributes param in the QueryCommand but the result still not contains the document body.
const command = new QueryCommand({
IndexId: 'xxxxxxx',
QueryText: "How to connect to ec2?",
RequestedDocumentAttributes: [
"_document_body",
"_data_source_id",
"_last_updated_at"
]
});
Any suggestion?
_document_body is a special field and Kendra currently does not support returning its entire value in the Query response. Kendra does returns a DocumentExcept for each document ResultItem, which contains the most relevant extract of text in the _document_body.

Postman: ordering of fields in form-data request

I have a server set up to which I can successfully send the following request:
curl localhost:8081/graphql \
-F operations='{ "query": "mutation ($file: Upload!) { uploadFile(file: $file) { id } }", "variables": { "file": null } }'
-F map='{ "0": ["variables.file"] }'
-F 0=#a.txt
However, if I paste that into Postman, or try to build the request manually, I get an error on the server-side stating
Custom error: Misordered multipart fields; files should follow “map” (https://github.com/jaydenseric/graphql-multipart-request-spec).
But in Postman, I have defined the fields in that order:
Does Postman do anything on its own to re-order the fields? Is there anything I can do to control the order?
Update: Filed a bug with Postman here: https://github.com/postmanlabs/postman-app-support/issues/4461
This way worked for me,instead of giving file name as "0" I gave "nfile" and order I maintained same operations,map and nfile
Postman seems to order fields alphabetically so 0 would become the first field. I renamed my own file fields as "nfile1" etc.
But I found this question because I was able to read only the first file. And I'm not sure if it caused by the naming I'm using. But that way you can at least test with one file on Postman.
You can also use Altair GraphQL Client to test out your file upload implementation as explained here.

Is it possible to list users in a specific orgunit with the google admin sdk directory api?

Im using the Directory API in the Google admin SDK to manage users in Google domains.
I'm looking for a way to list users in a specific orgunit in the domain but I don't find any examples on how to achieve this.
According to the documentation https://developers.google.com/admin-sdk/directory/v1/reference/users/list the only valid query attributes are email, familyName and givenName.
The workaround im using today is to get all users in the domain and then filter the response.
This is possible using the query parameter.
Example:
/admin/directory/v1/users?domain=domain.com&query=orgUnitPath=/Sales
or, url encoded:
/admin/directory/v1/users?domain=example.com&query=orgUnitPath%3D%2FSales
Will return all users in the /Sales orgunit.
Full docs here.
Your findings are correct, there's no way to retrieve only users in a given OU. You can retrieve just email and OrgUnit using the fields parameter and then filter locally. Using fields should reduce traffic and improve efficiency somewhat.
I used the 'query' parameter as explained in https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/list and it works.
var optionalArgs = {
customer: 'my_customer',
orderBy: 'email',
query: "orgUnitPath='/A1 - Current Members'"
};
var response = AdminDirectory.Users.list(optionalArgs);

CF8 and Salesforce REST API - updating records

I'm trying to do integration with Salesforce using their REST API and CF8.
I got the OAuth bit working, getting data etc but now I'm trying to update some records in Contact table.
First I tought about doing it the "proper" way as their docs say -
Update a record using HTTP PATCH.
But CFHTTP doesn't support PATCH method.
So then I tried running a SOQL query:
UPDATE Contact SET MailingStreet = 'Blah Blah' WHERE Id = '003A000000Zp4ObIAJ'
but here I'm getting
{"message":"unexpected token: UPDATE","errorCode":"MALFORMED_QUERY"}
Does anyone have an idea how to do it?
You can create your own PATCH method if your client supports it, but there is an easier way. From the Force.com REST API Developer's Guide:
If you use an HTTP library that doesn't allow overriding or setting an
arbitrary HTTP method name, you can send a POST request and provide an
override to the HTTP method via the query string parameter
_HttpMethod. In the PATCH example, you can replace the PostMethod line
with one that doesn't use override:
PostMethod m = new PostMethod(url + "?_HttpMethod=PATCH");
In CF9 CFScript, using the method that Paddyslacker already suggested for adding _HttpMethod=PATCH to the URL:
private boolean function patchObject(required string sfid, required string type, required struct obj) {
local.url = variables.salesforceInstance & '/services/data/v' & variables.apiVersion &'/sobjects/' & arguments.type & '/' & arguments.sfid &'?_HttpMethod=PATCH';
local.http = new Http(url=local.url,method='post');
//... convert obj to a json string, add to local.http ...
local.httpSendResult = local.http.send().getPrefix();
}
We have a CF9 CFC that we wrote that wraps most of the REST API that we will be open sourcing soon. I'll come back and link to it when we do.

Django POST sub-dictionaries

I'm making the following request through command-line cURL:
curl -X POST http://localhost:8000/api/places/ -vvvv -d "place[name]=Starbucks"
However, when I try to access the parameters by calling
request.POST.getlist('place')
I get an empty array as a response. How can I access the sub-dictionary which I can then pass to the ORM?
Thanks,
Jamie
HTTP data elements can't have sub-elements. The data you have posted - as shown in the querydict - has been interpreted as a single element with key "place[name]" and value "Starbucks". So you can get it with request.POST["place[name]"].
It looks like you are sending a string, in that case try:
request.POST.get('place[name]')
If your are simulating a dropdown list you should send "place=Starbucks", however if you are trying to send an array you should try to convert you string to an array inside your python script.
In your command you can get ride of "-X POST" as the parameter -d is already an HTTP POST:
curl --help
...
-d/--data <data> HTTP POST data (H)
curl manual:
http://curl.haxx.se/docs/manual.html