Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 2579

Raspberry Pi OS • Use of curl vs. pycurl and correct syntax

$
0
0
Very new RPi user here – one week’s experience. I have 3 related questions:
1.Should I use pycurl or curl?
2.What would be the right syntax for the pycurl/curl command?
3.Is curl even the best way to run a json command?

I have successfully run a curl command on a Windows PC. For that I used:

Code:

curl.exe -d "{\"command\": \"sendCameraCommand\",\"cameras\": [\"GoPro 9464\"],\"cameraCommand\": \"startRecording\"}" http://192.168.0.108:809
The command comes from an app’s list of json commands https://www.toolsforgopro.com/cameratools_server, and the one that I want to run is:

Code:

{"command": "sendCameraCommand","cameras": ["GoPro 9464"],"cameraCommand": "startRecording"}
I developed the single line curl command after using RESTer to run the above json, and RESTer then telling me it used:

Code:

curl -X POST http://192.168.0.108:809 \    -d '{"command": "sendCameraCommand","cameras": ["GoPro 9464"],"cameraCommand": "startRecording"}'
plus a lot of time spent with escapes, etc, but I have a command that works on a Windows server (the one right at the top)

Now I need it to work on a RPi3 Buster which is happy with the curl command, just not with my syntax. So, back to the 3 questions:

1.Should I use pycurl or curl?
2.What would be the right syntax for the pycurl/curl command?
3.Is curl even the best way to run a json command?

Thank you

Statistics: Posted by Gerald_D — Fri Apr 12, 2024 9:56 am



Viewing all articles
Browse latest Browse all 2579

Trending Articles