I'm trying to send emails using mandrill email service but I get the following error:
[
{
"email": "pranav_withyou#hotmail.com",
"status": "rejected",
"_id": "daab0daa538a4fe9b161be709593be0b",
"reject_reason": "unsigned"
}
]
I am trying to send email using ajax call in javascript like :
$.ajax({
type: "POST",
url: "https://mandrillapp.com/api/1.0/messages/send.json",
data: {
"key": "RemovedforSecurityitscorrect",
"message": {
"html": "<p>Example HTML content</p>",
"text": $('#emailText').val(),
"subject": $('#emailSubject').val(),
"from_email": $('#fromEmail').val(),
"from_name": $('#fromName').val(),
"to": [{
"email": $('#toEmail').val(),
"name": $('#recipientName').val(),
"type": "to"
}],
"headers": {
"Reply-To": $('#fromName').val()
}
},
success: function (data) {
console.log("Email Sent");
},
error: function (xhr, status, error) {
console.log("Error while sending mail");
}
}
});
all values are coming to ajax call & call is made to server evident from response. What can be issue?
I got the reason, it was silly mistake. I was trying to send mail through my personal email id which is on different domain than to for which Mandrill is configured & verified.
Searching for the reason of error, I found that this error is sent from Mandrill when Mail sent from unverified domains or domains without valid SPF and DKIM records will be rejected with the reject_reason, unsigned.
For more information refer
https://mandrillapp.com/api/docs/messages.html
https://mandrill.zendesk.com/hc/en-us/articles/205582247-About-Domain-Verification
https://mandrill.zendesk.com/hc/en-us/articles/205582267-About-SPF-and-DKIM
For doing required setting related to SPF & DKIM for Mandrill please refer:
https://mandrill.zendesk.com/hc/en-us/articles/205582277-How-do-I-add-DNS-records-for-my-sending-domains-
Related
Im trying to send a request to a rest API and granted my knowledge using jquery is not advance however through numerous tutorials I'm struggling a bit to build a request based on this swagger documentation.
{
"fields": {
"": [
{
"NAME": "NAME"
},
{
"ADDRESS": "ADDRESS"
},
{
"EMAIL": "EMAIL"
}
]
}
}
This is the model of how i need to send the Rest request, im able to do this using postman however i struggle to do this in javascript.
var data = {};
var json = [{ "NAME": "name", "ADDRESS": "address", "EMAIL": "email" }];
data.fields ={json};
My problem is that in the model there is an empty quotation which im unable to replicate. I suspect that either the rest API is not the best or im missing something quite vital in building a request. See below for the actual ajax jquery request.
var request = $.ajax({
type: "POST",
url: urlBase,
contentType: 'application/json',
data: JSON.stringify({json}),
});
request.done(function (msg) {
alert(msg);
$("#log").html(msg);
});
request.fail(function (jqXHR, textStatus) {
alert("Request failed: " + textStatus);
});
}
Error message based on the above request
Invalid field groups: [json] used in the search fields not found in duplicate store schema
You can create a json like this:
var obj = {
"": [{
"NAME": "NAME"
},
{
"ADDRESS": "ADDRESS"
},
{
"EMAIL": "EMAIL"
}
]
}
console.log(obj)
Hope it helps. Revert for any doubts.
I send an access token in, that is valid by the Facebook Access Token Debugger, but it still says that it isn't an active/is an invalid access token
I have tried putting the access token through the debugger: Came up as active
var access_token = pathname.match(/\#(?:access_token)\=([\S\s]*?)\&/)[1];
$.ajax({
url: "https://graph.facebook.com/me?name?access_token=" + access_token,
type: 'GET',
success: function(response) {
console.log(response)
//Would want to do stuff with the Return data
},
error: function(response) {
$("#nameField").html("<li class='dataField' id='nameField'>The response could not locate the data source</li>")
}
});
I would want it to return JSON data/Single JSON entry. Ends up showing:
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "BdmIzcoyALS"
}
}
Nevermind, found the answer:
It was the fact that I was using:
https://graph.facebook.com/me?name?access_token=
When I should have used:
https://graph.facebook.com/me?name&access_token=
I am trying to test Google Cloud analyzeSyntax from JavaScript, forming an ajax request using jQuery, but I keep getting errors returned. I obviously don't understand how to form the call properly but cannot find any answers or examples that match what I am trying to do.
The documentation for the call is
https://cloud.google.com/natural-language/docs/reference/rest/v1/documents/analyzeSyntax.
HTML
<!DOCTYPE html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="pm.js"></script>
</head>
<body>
<button onclick="analyzeSyntax();">Go</button>
<div id="results"></div>
</body>
</html>
JS
function analyzeSyntax() {
$.ajax({
type: "POST",
url: "https://language.googleapis.com/v1/documents:analyzeSyntax?key=XXXXXXXXXXXXX",
data: { "document" : {
"type":"PLAIN_TEXT",
"content":"I just want to try out analyzeSyntax",
},
encodingType: "UTF8"
},
success: function(data){
alert("success " + data.responseText);
},
error: function(data){
alert("error " + data.responseText);
}
});
}
ERROR
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"document[type]\": Cannot bind query parameter. Field 'document[type]' could not be found in request message.\nInvalid JSON payload received. Unknown name \"document[content]\": Cannot bind query parameter. Field 'document[content]' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"document[type]\": Cannot bind query parameter. Field 'document[type]' could not be found in request message."
},
{
"description": "Invalid JSON payload received. Unknown name \"document[content]\": Cannot bind query parameter. Field 'document[content]' could not be found in request message."
}
]
}
]
}
I'm trying to implement a simple POST call in meteor.js to the Google Calendar API, and I'm stuck. My request looks like this:
var id = Meteor.http.post("https://www.googleapis.com/calendar/v3/calendars/", {
'headers' : {
'Authorization': auth, // auth = "Bearer " + Meteor.user().services.google.accessToken
'Content-Type': 'application/json'
},
'parameters': {},
'body' : {
'title': "Calendar Title",
}
});
and I get the following error:
Error: failed [400] {
"error": {
"errors": [{
"domain": "global",
"reason": "required",
"message": "Missing title."
}],
"code": 400,
"message": "Missing title."
}
}
Any ideas?
Solved it. This is dumb.
Take out parameters, and make "body" "data" instead and it works.
I am trying to figure out how the payload should be constructed for a Open Graph object to submit to yammer. I can post a standard message, but i would like to post an opengraph message instead.
{
"activity":{
"actor":{"name":"Sidd Singh",
"email":"sidd#xyz.com"},
"action":"create",
"object": {
"url":"https://www.sched.do",
"title":"Lunch Meeting"
},
"message":"Hey, let’s get sushi!",
"users":[
{"name":"Adarsh Pandit",
"email":"adarsh#xyz.com"}
]
}
}
This is some code nicked from their API documentation but doesn't show me how i should use this in javascript. Can someone assist me? Below is my existing code that posts a standard message...
yam.request({
url: "https://www.yammer.com/api/v1/messages.json?network_id=networkname", //this is one of many REST endpoints that are available
method: "POST",
beforeSend: function (req) { //send the access_token in the HTTP header
req.headers.Authorization = "Bearer " + access_token;
},
data: {
"network": "networkname",
"body": "Test Post",
"group_id": "3719771"
},
success: function (data) { //print message response information to the console
toastr.success('An Item was successfully posted to Yammer', "Yammer Network");
},
error: function (user) {
toastr.error('There was an error eith the request', "Yammer Network");
}
});
This post answered your question: Yammer Open Graph API Error 400
Simply replace the key value pairs in the data{} with the activity json strings. Also remember to change the RESTful api endpoint to https://api.yammer.com/api/v1/activity.json