Pocster Posted April 25, 2023 Posted April 25, 2023 Jesus! - for the love of God just give me C and an assembler! I'm fighting here! ; simple to someone that knows curl - I'm on windows aswell so I'm even more annoyed than usual! Here's what I'm trying to achieve .... curl -H 'Content-Type: application/json' -X PUT -d '{"configured": true}' http://IP:PORT/api/APIKEY/sensors/ID/config ip:port my HA, APIKEY I got. It's which brackets of which type with which quotes where - that I can't get right. Googling is just adding fuel to the flames. One of you will be some modern sado web page type deal with this mess person ( and much appreciated I will be! )
jack Posted April 25, 2023 Posted April 25, 2023 Get into GPT. Apparently this is exactly the sort of problem it's ideal for solving. 1
Pocster Posted April 25, 2023 Author Posted April 25, 2023 5 minutes ago, jack said: Get into GPT. Apparently this is exactly the sort of problem it's ideal for solving. Yeah . Didn’t think of that . Certainly worth a shot !
Pocster Posted April 25, 2023 Author Posted April 25, 2023 58 minutes ago, jack said: Get into GPT. Apparently this is exactly the sort of problem it's ideal for solving. It says it’s correct for a json payload …
Pocster Posted April 25, 2023 Author Posted April 25, 2023 Just now, pocster said: It says it’s correct for a json payload … Better check I’ve got a json payload ! 1
elite Posted April 25, 2023 Posted April 25, 2023 What error are you getting? I think windows isn't a fan of the single quotes on the json - try escaping the inner ones curl -XPUT -H "Content-type: application/json" -d "{\"configured\": true}" http://IP:PORt/api/APIKEY/sensors/ID/config
Sparrowhawk Posted April 25, 2023 Posted April 25, 2023 Since you're on Windows, can you install Windows Subsystem for Linux (WSL)? It makes tasks like this much easier (I have run out of patience with curl on Windows). Alternatively use Postman (it's free) and run the command there instead of at the command line.
Pocster Posted April 25, 2023 Author Posted April 25, 2023 22 minutes ago, elite said: What error are you getting? I think windows isn't a fan of the single quotes on the json - try escaping the inner ones curl -XPUT -H "Content-type: application/json" -d "{\"configured\": true}" http://IP:PORt/api/APIKEY/sensors/ID/config Mucking windows! > tried as you suggested get rescue/sensors/2, not available, "type 3" error now
Pocster Posted April 25, 2023 Author Posted April 25, 2023 5 minutes ago, Sparrowhawk said: Since you're on Windows, can you install Windows Subsystem for Linux (WSL)? It makes tasks like this much easier (I have run out of patience with curl on Windows). Alternatively use Postman (it's free) and run the command there instead of at the command line. I thought ( after googling ) I had chrome postman add on. But can't see how I do a CURL in it ; just post/get etc.
Sparrowhawk Posted April 25, 2023 Posted April 25, 2023 (edited) 2 minutes ago, pocster said: I thought ( after googling ) I had chrome postman add on. But can't see how I do a CURL in it ; just post/get etc. https://www.tutorialspoint.com/how-to-create-a-put-request-in-postman You're replicating the cURL command inside Postman. It's a different syntax but does allow you to save these commands in a playbook to rerun in future. Edited April 25, 2023 by Sparrowhawk
elite Posted April 25, 2023 Posted April 25, 2023 3 minutes ago, pocster said: Mucking windows! > tried as you suggested get rescue/sensors/2, not available, "type 3" error now Add quotes around the URL? curl -XPUT -H "Content-type: application/json" -d "{\"configured\": true}" "http://IP:PORt/api/APIKEY/sensors/ID/config"
Pocster Posted April 25, 2023 Author Posted April 25, 2023 Just now, elite said: Add quotes around the URL? curl -XPUT -H "Content-type: application/json" -d "{\"configured\": true}" "http://IP:PORt/api/APIKEY/sensors/ID/config" Tried that
Sparrowhawk Posted April 25, 2023 Posted April 25, 2023 Postman can also import curl commands, see https://www.shipengine.com/docs/curl/#running-curl-examples-in-postman (I ****** hate Postman but it does have its uses) 1
elite Posted April 25, 2023 Posted April 25, 2023 2 minutes ago, pocster said: Tried that Works for me - things I'd check Weird characters in api key - should've been fixed with quotes Is the URL / path you're hitting 100% correct? Try with verbose flag (-v)
Pocster Posted April 25, 2023 Author Posted April 25, 2023 5 minutes ago, Sparrowhawk said: Postman can also import curl commands, see https://www.shipengine.com/docs/curl/#running-curl-examples-in-postman (I ****** hate Postman but it does have its uses) Modern stuff is soooooo shite. Used postman with import to do curl and got error resource, /sensors/2/config, not available
Pocster Posted April 25, 2023 Author Posted April 25, 2023 7 minutes ago, elite said: What service are you connecting to? Do you know . I can’t answer that . I’m following some German advice that I need to connect to a local physical advice to change configured from false to true . It’s insane how convoluted this is - and I’ve still not achieved it . I do appreciate all the help though ! BIT_SET(*(device,).configuration,TRUE); ( apologies if syntax a little rusty ! )
elite Posted April 25, 2023 Posted April 25, 2023 Are you getting a http status code back -v flag in curl - postman in chrome will prob give you this too? - this might give a clue as to an error (prob 5** range) or not found 4** - Is it definatley device ID 2? This should begiving you a 200 if all is good Happy to cast a second pair of eyes over the german advice if you want to PM
Pocster Posted April 26, 2023 Author Posted April 26, 2023 Trying to import curl command in postman and the error is "2 options less arguments found, only 1 is supported (the URL)"
Pocster Posted April 26, 2023 Author Posted April 26, 2023 An extra space believe it or not - which you couldn't 'see' as the curl line was split. Things like this shouldn't exist in 2023. Like on a webpage where you must enter the date and then it complains you need to put spaces in ( no; your code should do that ). Seems to be a common thing with postcode enteries. Don't get it. Validate the input pad/remove spaces etc. - basic stuff ffs! Anyway! - did my curl and something else is a miss now ( I was told the device id was 2 ; but I reckon it's 6 ) - either way inching forward... 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now