I just want to know why when I send variables using a template, the Mailjet API doesn't replace them, even the fakeFirstname doesn't show.
I just see {{var:FirstName:"fakeFirstName"}}
Here is my payload :
{
"Messages": [
{
"From": {
"Email": "senderEmail",
"Name": "senderName"
},
"To": [
{
"Email": "userEmail",
"Name": "userName"
}
],
"Subject": "subject",
"TextPart": "",
"HTMLPart": "",
"TemplateID": TemplateId,
"TemplateLanguage": true,
"Variables": {
"FirstName": "otherName"
}
}
]
}
Thanks for the helpers.
Related
I'm using a dynamic template in SendGrid to send transactional emails that typically go to multiple recipients in the personalizations field. The message body includes custom_args that are shared among all recipients, and in personalizations, both custom_args and dynamic_template_data specific to each recipient. Webhook events return the shared custom_args, but none of the recipient-specific custom_args. Is there a way to get events together with the personalized custom_args? Here's an example request body where we add a userId custom_arg for each recipient:
{
"from": {
"email": "sender#example.com",
"name": "Example Sender"
},
"personalizations": [
{
"to": [
{
"email": "recipient1#example.com",
"custom_args": {
"userId": "63r20acm4xfv"
}
}
],
"dynamic_template_data": {
"subject": "New Article",
"description": "Read the lastest news on...",
"documentId": "624dxnpvhw8g",
"host": "https://localhost:8000",
"userId": "63r20acm4xfv"
}
}
],
"custom_args": {
"documentId": "624dxnpvhw8g"
}
}
And the webhook events we receive (the "documentId" custom arg is reported, but not the "userID" custom_arg from personalizations):
[
{
"documentId": "624dxnpvhw8g",
"email": "recipient1#example.com",
"event": "processed",
"sg_event_id": "cHJvY2Vzc2VkLTI3MTk3NzMzLUtTUEJOaVpGUXpXb05KblctVDBNRkEtMA",
"sg_message_id": "KSPBNiZFQzWoNJnW-T0MFA.filterdrecv-58c58fcb9f-44vrp-1-6312139C-1F6.0",
"sg_template_id": "d-1ebc6b474b7041c0b439d1bdb17650e4",
"sg_template_name": "DEFAULT TEMPLATE",
"smtp-id": "<redacted>",
"timestamp": 1662128000
},
{
"documentId": "624dxnpvhw8g",
"email": "recipient1#example.com",
"event": "delivered",
"ip": "<redacted>",
"response": "250 Message received",
"sg_event_id": "ZGVsaXZlcmVkLTAtMjcxOTc3MzMtS1NQQk5pWkZReldvTkpuVy1UME1GQS0w",
"sg_message_id": "KSPBNiZFQzWoNJnW-T0MFA.filterdrecv-58c58fcb9f-44vrp-1-6312139C-1F6.0",
"sg_template_id": "d-1ebc6b474b7041c0b439d1bdb17650e4",
"sg_template_name": "DEFAULT TEMPLATE",
"smtp-id": "<redacted>",
"timestamp": 1662128002,
"tls": 1
}
]
Ugh - the custom_args in personalizations was at the wrong level. After moving the custom_args up to the same level as the dynamic_template_data, it worked fine and the values are included in the webhook events.
The example from the question was changed to:
{
"from": {
"email": "sender#example.com",
"name": "Example Sender"
},
"personalizations": [
{
"to": [
{
"email": "recipient1#example.com",
}
],
"custom_args": {
"userId": "63r20acm4xfv"
}
"dynamic_template_data": {
"subject": "New Article",
"description": "Read the lastest news on...",
"documentId": "624dxnpvhw8g",
"host": "https://localhost:8000",
"userId": "63r20acm4xfv"
}
}
],
"custom_args": {
"documentId": "624dxnpvhw8g"
}
}
{
"headers": {},
"endpoint": "mail/send",
"method": "POST",
"queryParams": {},
"baseUri": "",
"body": {
"from": {
"name": "Test",
"email": "test#noreply.com"
},
"subject": "Test Send Grid Mail Service",
"personalizations": [
{
"to": [
{
"email": "user#test.com"
}
],
"subject": "Test Send Grid Mail Service",
"custom_args": {
}
},
{
"to": [
{
"email": "user#test.com"
}
],
"subject": "Test Send Grid Mail Service",
"custom_args": {
}
}
],
"content": [
{
"type": "text/html",
"value": "Hi"
}
]
}
}
I'm using this request body to send multiple emails(in this case 2 emails) to the same user but the send grid is sending only one email. Is there a way to send multiple emails to the same user multiple times(in this case 2 emails) in a single send grid request?
I'm using Netsuite's Postman collection (which takes care of the Oauth1 stuff), and am POSTing to this endpoint:
{{proto}}://{{host}}/rest/platform/{{version}}/record/salesorder
... and the body is something like this:
{
"customForm": "999",
"entity": {
"id": "1111"
},
"department": {
"id": "2222"
},
"subsidiary": {
"id": "33"
},
"otherRefNum": "TEST-PO",
"location": {
"id": "444"
},
"item": {
"items": [
{
"item": { "id": "555555" },
"inventorylocation": { "id": "444" },
"price": { "id": "-1" },
"grossAmt": 999,
"quantity": 1
}
]
}
}
I'm trying to assign a location on the item level. The above request creates a sales order ok (without the line-level location assignment) if I remove the inventorylocation line, but with that in there, I get this error: Unknown reference or subrecord field inventorylocation in request body.
Netsuite's REST API documentation is here:
https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2019.2/index.html#tag-salesorder
I have also tried substituting location and moving the fields around a bit, without success. (either the salesorder is created without a line-level location assignment, or I get an error similar to the above error.
Any ideas?
From the documentation you linked, it appears that the field id you need is inventorylocation rather than itemlocation.
salesorder-itemElement
...
giftCertRecipientName Recipient Name: string
id [Missing Label:id]: string
inventorydetail: salesorder-item-inventorydetail
inventorylocation: location
inventorysubsidiary: subsidiary
isClosed Closed: boolean
...
Based on the documentation for a salesOrder-itemElement, it looks like that key is correct.
Have you tried the "location": "{ID}" variation?
In LedgerSync it looks like the request for creating an invoice results in this body:
{
"entity": "309",
"location": "1",
"sublist": {
"items": [
{
"amount": 12345,
"description": "Test Line Item FLURYAOLJLFADYGR-1"
},
{
"amount": 12345,
"description": "Test Line Item FLURYAOLUFUTBYJD-2"
}
]
}
}
There also is a salesOrder-item-inventorydetail object that also contains a location. Perhaps you could use that one like so:
{
"customForm": "999",
"entity": {
"id": "1111"
},
"department": {
"id": "2222"
},
"subsidiary": {
"id": "33"
},
"otherRefNum": "TEST-PO",
"location": {
"id": "444"
},
"item": {
"items": [
{
"item": { "id": "555555" },
"inventorydetail": {
"location": "444"
},
"price": { "id": "-1" },
"grossAmt": 999,
"quantity": 1
}
]
}
}
I'm using loopback 3 to build a backend with mongoDB.
So i have 3 models: Object, Attachment and AwsS3.
Object has a relation Embeds2Many to Attachment.
Attachment has a relation Many2One to AwsS3.
Objects look like that in mongoDB
[
{
"fieldA": "valueA1",
"attachments": [
{
"id": 1,
"awsS3Id": "1234"
},
{
"id": 2,
"awsS3Id": "1235"
}
]
},
{
"fieldA": "valueA2",
"attachments": [
{
"id": 4,
"awsS3Id": "1236"
},
{
"id": 5,
"awsS3Id": "1237"
}
]
}
]
AwsS3 looks like that in mongoDB
[
{
"id": "1",
"url": "abc.com/1"
},
{
"id": "2",
"url": "abc.com/2"
}
]
The question is: how can i get Objects included Attachment and AwsS3.url over the RestAPI?
I have try with the include and scope filter. But it didn't work. It look like, that this function is not implemented in loopback3, right? Here is what i tried over the GET request:
{
"filter": {
"include": {
"relation": "Attachment",
"scope": {
"include": {
"relation": "awsS3",
}
}
}
}
}
With this request i only got the Objects with Attachments without anything from AwsS3.
UPDATE for the relation definitons
The relation from Object to Attachment:
"Attachment": {
"type": "embedsMany",
"model": "Attachment",
"property": "attachments",
"options": {
"validate": true,
"forceId": false
}
},
The relation from Attachment to AwsS3
in attachment.json
"relations": {
"awsS3": {
"type": "belongsTo",
"model": "AwsS3",
"foreignKey": ""
}
}
in AwsS3.json
"relations": {
"attachments": {
"type": "hasMany",
"model": "Attachment",
"foreignKey": ""
}
}
Try this filter:
{ "filter": { "include": ["awsS3", "attachments"]}}}}
I have tried Page Messages
with the all the required permission i.e read_mailbox, read_page_mailboxes, etc (all the extended permission)
at length I get tried as
https://graph.facebook.com/456330641095467/conversations?access_token=BAAGgcfpJgfUBAHdKaE6KxMWo4rU6VU7psX7Ip4cLbG1yIvX80fkkTXm3ZApdYHmcISmqfnns1gPYZAHXWD2cXX7nMBcj4AK31uptfqJUjNAGXan1ftOK4Tw3sY1WsZD
but i get response as
{
"error": {
"message": "(#210) Subject must be a page.",
"type": "OAuthException",
"code": 210
}
}
I am unable to find out the issue. Please help.
Just use the access_token of page and you are done
yours output would be like this
{
"data": [
{
"id": "t_id.615971188431960",
"snippet": "ok fine reply on test 5:15",
"updated_time": "2013-04-16T12:15:12+0000",
"message_count": 8,
"tags": {
"data": [
{
"name": "inbox"
},
{
"name": "read"
},
{
"name": "seen"
},
{
"name": "sent"
},
{
"name": "source:web"
}
]
},
"participants": {
"data": [
{
"name": "Pragati Singh",
"email": "100000441901858\u0040facebook.com",
"id": "100000441901858"
},
{
"name": "Devdemo",
"email": "456330641095467\u0040facebook.com",
"id": "456330641095467"
}
]
},
"senders": {
"data": [
{
"name": "Devdemo",
"email": "456330641095467\u0040facebook.com",
"id": "456330641095467"
},
{
"name": "Pragati Singh",
"email": "100000441901858\u0040facebook.com",
"id": "100000441901858"
}
]
},