Help with RESTful API?

I have setup IFTTT/Maker to take some actions through the API and it’s working great, however when I try to connect to the API with postman for testing or from other services, I keep getting “500 Internal Server Error” in response. I probably just don’t know what I’m doing.

I can connect and get a good response to the API for a GET config request at this address, so I know I’m not locked out:

I can send a POST request to this address and shut off all the lights:

However, when I try to add a payload I get the internal server error. I’m guessing my formatting is wrong somehow.

I have this header:
‘Content-Type’ = ‘application/json’

and this body:
‘entity_id’ = ‘light.bedroom’

There is an open issue:

Thanks but I don’t think these are related. In fact, I just made a breakthrough. I am able to make the request in Postman but only if I format the body of the message as “raw” and type it exactly as:

I can’t get it to work by filling in the ‘key’ and ‘value’ fields. Unfortunately, that’s the only option I have for the Application I plan to use this from, which is the SmartThings CoRE smartapp.

What can I do to properly format the JSON body as key/value to make it work with HA?

Is there a way to format the entire URL to do what I want without having to use the ‘header’ or ‘body’? That would work for me.

Yeah, HASS is a little picky about the API. There’s not a way to use it without the header, and JSON is passed as the body. FWIW, looks like you got the format right for the body JSON. You can use the services dev tool to test json payloads.

Rats, sounds like I won’t be able to do what I wanted as I don’t have an option to send RAW JSON from SmartThings CoRE.

It’s too bad there’s no ability to do simple services actions from just a coded URL.

In a pinch, you could write your own helper app. Have it take a series of inputs and format a cURL call to the HASS API.

Thanks for the suggestion! I love that idea but it’s a bit over my head. Do you have a link to a totorial or example I could study?

No. You’d need to have a basic knowledge of a programming language and a server to run the script from.

Ill paste this here as i dont really know where else to paste it as a helpful snippet
I find the best way to resolve rest issues is to use postman (download it)
get all your comms working
and then follow this guide to get payload from selecting python language

this is especially helpful when create raw requests such as i did for travel details with entur (norway) which used a graphql raw payload