Call AWS API from Photon

Hello guys. I just want to call a Post API from my Photon but I can’t find code that does this type of job. Note the API is an AWS gateway API service that they use on AWS.

What have you tried? Where have you looked? What exactly isn’t working?

Using HTTP or HTTPS?

1 Like

Https

I have tried to use goldfish.sh and the HttpClient library’s

I would suggest looking into the Particle Webhook API. It allows you to use Particle.publish/Particle.subscribe to communicate with outside services (including over encrypted HTTPS).

See the tutorial at https://docs.particle.io/tutorials/device-cloud/webhooks/ and more in-depth documentation at https://docs.particle.io/reference/device-cloud/webhooks/.

3 Likes

It is pretty easy to do a publish and setup an integration to publish to any API. I have code that does just that to AWS API Gateway running now. If you need to go directly to AWS you may have some issue with certificates etc. for HTTPS. If you can go from Photon to Particle Cloud via an event and use an integration you can be up and running in under an hour. LMK if you need any help or pointer.

WDYM? I know that you can publish a API and if you are using web hooks you can use the particle.publish but all i need is the photon to call a POST request and send data to trigger my lambda function. Also i am looking for the code to do this and that’s it. Plus The Particle Console Interrogations Tab don’t support AWS support only Azure IoT

But i am going to be setting up multiple devices and if i use Webhook they all get through into one big pile at least that how i know it and i tried to use thingspeak but i don’t need a graph i tried to send my device id’s to store the temperature for each one but that wasn’t working either

Can integrate with 3rd party services, just need to configure everything explicitly. Select the standard Webhook not the Azure IoT option.

See https://docs.particle.io/reference/device-cloud/webhooks/#custom-variables

Using JSON for your published event data provides custom fields that the webhook can then use to template its operation. So rather than POST to a hardcoded target you could use {“aws_device”:1234} as your event data and in the webhook configuration use {{{aws_device}}} which will be substituted with 1234. The {{{aws_device}}} substitution can be in the URL, header fields, the HTTP body, etc. So configure your devices appropriately, include necessary fields as JSON in event data, and template your webhook to meet the needs of your AWS integration.

1 Like

Exactly, I am using a generic particle webhook to post each publish to AWS API gateway and call a lambda that stores temp and humidity data in dynamodb for each device.

If you want to roll your own this might help

There are some other posts too that I can try and find when I get on a real computer (not my phone). :roll_eyes:

Here is the code for the lambda my gateway calls when the webhook fires:

2 Likes

Look here: https://www.hackster.io/nicjansma/particle-photon-remote-temperature-and-humidity-logger-00dd00