cancel
Showing results for 
Search instead for 
Did you mean: 
Super User

NASA API Integration using Microsoft Flow

In this blog, I will explain how to call an API (Application Programming Interface) using Microsoft Flow.

 

Here I am using NASA API Astronomy picture of the day (APOD). The plan is to retrieve the picture of the day using the API and store in a SharePoint document library.

 

References:

NASA API Website https://api.nasa.gov/

API Method:  https://api.nasa.gov/planetary/apod.

Below are the related query parameters for the APOD API Get method.

 
 
 

Above date and hd parameters are optional. To generate an API Key you need to register your name, email and follow the instructions from the website (https://api.nasa.gov/).

Now we can start building the Flow. Here I am using a scheduled trigger which triggers every day.

a2.png

 

Next, we need to use the HTTP flow step. Here copy the api_key which you received as part of the registration process. You can also extend the query parameters using date and hd which are optional.

a3.png

 

The response from the above step HTTP  request will be in JSON format.

a4.png

 

JSON schema is as follows:

{

    "type": "object",

    "properties": {

        "date": {

            "type": "string"

        },

        "explanation": {

            "type": "string"

        },

        "hdurl": {

            "type": "string"

        },

        "media_type": {

            "type": "string"

        },

        "service_version": {

            "type": "string"

        },

        "title": {

            "type": "string"

        },

        "url": {

            "type": "string"

        }

    }

}

 

Next, we need to get the image and store in SharePoint. To get the image content I am using another HTTP flow method and passing the image hdurl.  For the API call we are using the GET method.

a5.png

 

Next I am using a compose flow step to get the filename of the image using JSON response url property.

Above expression is as follows:

last(split(body('Parse_JSON_Results')?['url'],'/'))

 

Finally, we have all the necessary attributes to create the file in SharePoint.

a7.png

 

Here is the final preview of the flow.

a8.png

 

Thank you for reading!

Comments

I made a video on this same topic some time back. 
youtu.be/-GVu1EsKfvo

Meet Our Blog Authors
  • Working daily with Microsoft Cloud to deliver the needs of my company, my customers and various Microsoft communities and forums. | Office 365 | Flow | PowerShell | PowerApps | SharePoint |
  • Co-founder of https://plumsail.com, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Daniel is a Business Productivity Consultant & Microsoft Business Solutions MVP who is very enthusiastic about all things Office 365, Microsoft Flow, PowerApps, Azure & SharePoint (Online). Since the preview, Daniel has been working with Microsoft Flow and later on with Microsoft PowerApps. That led to him being awarded an MVP Award for Business Solutions. He loves to blog, present and evangelize about improving productivity in the modern workspace with these amazing tools!
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc ( https://triad.co.uk)
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor