how can i post data using Mozilla rest add-on using mailgun api - json

I'm using this Mozilla ADD-ON to post the data in mailgun API
RestClient
Content-Type:application/json
URL I'm using
https://api.mailgun.net/v2/sandbox42924.mailgun.org/messages
Json Data I'm posting
[
{
"from": "Kaushik <kaushik#gmail.com>"
},
{
"to": "Kaushik <kaushikfb1#gmail.com>"
},
{
"subject": "Hello This is test mail"
},
{
"text": "Testing some Mailgun !"
},
{
"html": "<html>Hello These <h2>contents belongs</h2> to html content</html>"
}
]
OR
{
"from": "Kaushik <kaushik#gmail.com>",
"to": "Kaushik <kaushikfb1#gmail.com>",
"subject": "Hello This is test mail",
"text": "Testing some Mailgun !",
"html": "<html>Hello These <h2>contents belongs</h2> to html content</html>"
}
In both cases what I'm getting is
{
"message": "'from' parameter is missing"
}
I want to know how i can post the data.
In documentation they have not describe this process.
I'm curious to know how it is working?
Here is the link for the documentation Click Here. They are using library for using in each language. If you know the library in detail you can help.

Finally I found the answer of this so for the sake of other user so they may find a help from this post in future I'm submitting the answer.
the url is this one.
https://api.mailgun.net/v2/yourdoamin.com/messages
username = api
password = {your key}
Now after that set your content type:application/x-www-form-urlencoded.
Now post the data. for formatting the data you can use this link Click Here
Demo data format
from%3D%27Excited%20User%20%3Cme%40yourdoamin.com%3E%27%20%5C%0A%20%20%20%20%20to%3Dbaz%40example.com%5C%0A%20%20%20%20%20to%3Dbar%40example.com%20%5C%0A%20%20%20%20subject%3D%27Hello%27%20%5C%0A%20%20%20%20text%3D%27Testing%20some%20Mailgun%20awesomness!%27

Related

Slack JSON - Custom Bot Username and Icon

I'm looking to send out a Post json request using Zapier's webhook function, together with Slack's incoming webhook set up.
I'm using block kit to develop the message style, and so far that's worked great. However, I'd like my bot to display with a custom username and emoji/icon and I'm having trouble.
Here is the JSON payload I'm trying, based off this tutorial https://api.slack.com/methods/chat.postMessage#args
The post seems to ignore the first two lines and posts as the standard bot name
{
"as_user": false,
"username": "test",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*78 Varet St #14*\n 2 Bed / $2300 \n <#ben> \n 3rd Deposit This Month"
},
"accessory": {
"type": "image",
"image_url": "https://p.sharinpix.com/3/3521a32/YXBwLnNoYXJpbnBpeC5jb20vaW1hZ2VzL2I2M2RkZTY4LWZkMDMtNGZlYy04OGUxLWYwZjA0N2E4NjQ3NS90aHVtYm5haWxzL29yaWdpbmFsLWI5MTdlNzAzY2U2LmpwZw/77-varet-st-building.jpg?timestamp=1639154285",
"alt_text": "cute cat"
}
},
{
"type": "divider"
}
]
}
Any help would be greatly appreciated!
If you just want to modify the icon and name of your bot ( will be the same throughout the app ), you should be able to do that on https://api.slack.com/apps/{YOUR_APP_ID}/general? under the Display Information section.
If you want to be able to change it from message to message, you will have to grant your app additional permissions scopes. See https://api.slack.com/methods/chat.postMessage#authorship

Sending dynamic variables in sendgrid v3 body using postman

I am trying to send the emails via Sendgrid using v3 API using postman, I have created 3 separate variables in 3 different requests, I want to pass all those 3 variables in a single mail, for that I have used below sendgrid
https://api.sendgrid.com/v3/mail/send
with below body
{
"personalizations": [
{
"to": [
{
"email": "testing#test.com",
"name": "API Testing"
}
],
"subject": "API testing successful"
}
],
"from": {
"email": "noreply#testApi.com",
"name": "API Testing"
},
"content": [
{
"type": "text/plain",
"value": "{{variable1}}" //In variable1 has a dynamic values
}
]
}
but the above format sending the mail body as {{Variable1}}, can someone help me on this?
For handlebar {{ variable_value }} substitutions in dynamic HTML templates, u need to pass the variable value as JSON structure with the key as "dynamic_template_data" as part of personalizations.
U also need to pass the (API Key) Authorization as "Authorization: and Value as "Bearer ".
In the Request Body pass the personalizations object.
{
"personalizations": [
{
"to": [
{
"email": "ron#***",
}
],
"dynamic_template_data": {
"<variable_name>": <variable_value>
}
}
],
"from": {
"email": "development#crosspaymt.com",
"name": "Development Team"
},
"content": [
{
"type": "text/html",
"value": "replace body with template content"
}
],
"template_id": "******"
}
From what I understand of the question you want to send multiple requests with different values.
Say, GET to https://google.com/q={{search}} and you have multiple search queries, (dog, chess, marvel, stackoverflow)
Create a collection in postman
Add a GET request to https://google.com/q={{search}} with necessary headers and hit Save
Create a CSV file with the header search and all search values under it
Hit the run button for the newly created collection
Set the Iterations field to the number of queries you have. In this example it is 4
Look for the field Data, select the created CSV file
Ensure the data is correctly being picked up by hitting the Preview button
Hit Run test
You can view the output in the Postman Console
To open Postman Console Head to View in the application menu, and click on "Show Postman Console" or use the keyboard shortcut (CMD/CTRL + ALT + C) to open.

OneNote API Get Notebooks issue

The following is a sample schema from the OneNote API documentation at this site and will can be used with json2csharp.com with no problems.
http://dev.onenote.com/docs#/reference/get-notebooks.
{
"createdBy": "user name",
"createdTime": "2013-10-05T10:57:00.683Z",
"id": "notebook ID",
"isDefault": false,
"isShared": false,
"lastModifiedBy": "user name",
"lastModifiedTime": "2014-01-28T18:49:00.47Z",
"links": {
"oneNoteClientUrl": {
"href": "onenote:https://{client URL}"
},
"oneNoteWebUrl": {
"href": "https://{web URL}"
}
},
"name": "notebook name",
"sectionGroupsUrl": "https://www.onenote.com/api/v1.0/notebooks/{notebook ID}/sectionGroups",
"sectionsUrl": "https://www.onenote.com/api/v1.0/notebooks/{notebook ID}/sections",
"self": "https://www.onenote.com/api/v1.0/notebooks/{notebook ID}",
"userRole": "Contributor"
}
However, using the following Get Notebooks link has a different schema that doe
sn't pass json2csharp. Parsing your JSON didn't work. Please make sure it's valid.
"https://graph.microsoft.com/v1.0/me/onenote/notebooks"
createdBy and lastmodifiedBy are thrown as exceptions.
The sample from the apigee.com/console app uses the https://www.onenote.com/api/v1.0/me/notes/notebooks link and has the correct schema.
How do I resolve this discrepancy? Or am I mistaken?
The response payload returned from the Microsoft Graph API is slightly different from the response payload returned from the OneNote API directly.
Here's a reference to the notebook properties returned from Microsoft Graph: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/notebook
And this is what gets returned from the OneNote API directly:
https://msdn.microsoft.com/en-us/library/office/dn769050.aspx => Response properties

Graph API: Check if feed post was made by a Page or User

When using the /page/feed endpoint in the Facebook Graph API I can't figure out how to know if the post was made by a Page or a User
Here's how I call the endpoint right now:
HTTP GET https://graph.facebook.com/v2.8/{page_id}/feed?fields=is_published,from,message
This yields the following JSON response:
{
"data": [
{
"from": {
"name": "Chad Smith", # <-- This is a User
"id": "806273209398023"
},
"message": "A really magical place! Best Christmas...",
"id": "103988597020_1445496708809010"
},
{
"from": {
"name": "Tivoli", # <-- This is a Page
"id": "103988597020"
},
"message": "Hello everybody...",
"id": "103988597020_10154040865527021"
},
]
}
How can I know if the post was from a Page or User without making additional API calls? I've tried using subfields, but can't figure out if they work on the from field.
I solved it by using ?fields=from{name,about} and marking it as a Page if the from JSON contains about.
This is not the best solution, but about is currently the only subfield of from that doesn't fail on User. (e.g. if I was using ?fields=from{fan_count} the Graph API will fail for posts made by User objects.

Authenticate to custom OpenAM 12 authentication plugin via REST

Would like to know how to authenticate to (for example):
http://www.example.com:8080/openam/UI/Login?realm=CUR&module=CURAuthn
preferably by POSTing JSON via REST over /json/authenticate.
I'm guessing it would be http://www.example.com:8080/openam/UI/Login?realm=CUR&authIndexType=module&authIndexValue=CURAuthn correct?
In any case this module doesn't take the standard X-OpenAM-Username or X-OpenAM-Password headers.
It takes a bunch of custom fields, called ID tokens. For instance it uses IDToken1, IDToken2, IDToken3, ...
How should I go about submitting the tokens to this plugin using the json authentication service? Thanks
All this is explained in the OpenAM's Developer's Guide section 3.4.
The REST URL for your custom module would be:
http://www.example.com:8080/openam/json/authenticate?authIndexType=module&authIndexValue=CURAuthn
If you module doesn't use the standard username/password credentials you'll have to pass your credentials in the request body as JSON.
You would start by sending a empty POST request to OpenAM:
$ curl \
--request POST \
--header "Content-Type: application/json" \
http://www.example.com:8080/openam/json/authenticate?authIndexType=module&authIndexValue=CURAuthn
You should get a response similar to this (based on your custom callbacks):
{
"authId": "eyAid...GDYaEQ",
"template": "",
"stage": "Module11",
"header": "Using CURAuthn",
"callbacks": [
{
"type": "NameCallback",
"output": [
{
"name": "prompt",
"value": "FirstCallback"
}
],
"input": [
{
"name": "IDToken1",
"value": ""
}
]
},
{
"type": "NameCallback",
"output": [
{
"name": "prompt",
"value": "SecondCallback"
}
],
"input": [
{
"name": "IDToken2",
"value": ""
}
]
},
//More callbacks here
]
}
After that just collect the credentials from the user input, fill in the empty values and submit the JSON payload back to the same URL. Make sure you use the same "authId" throughout the authentication process.
I wrote a blog post about custom authentication chains and how to communicate with them via REST. Take a look, it might be helpful.