Author Topic: send cURL requests via the windows command prompt...  (Read 4552 times)

mkeymont

  • Guest
send cURL requests via the windows command prompt...
« on: July 14, 2017, 04:41:30 PM »
Hi,
I have a curl request that works perfectly from the command prompt, but when I send it via VA, I get a "malformed JSON" error. Since I'm getting a response back in XML, I know that the command is being run, but something is getting messed up along the way.

Specifically, I'm sending a curl request to simply start Spotify playback.

Any ideas?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: send cURL requests via the windows command prompt...
« Reply #1 on: July 14, 2017, 06:03:59 PM »
If it works via command prompt, you could try having VoiceAttack run a batch file that in turn runs curl.

Though, it'd be good to diagnose this so it can be fixed in future. What does your request look like(what are you passing to curl), and how do you have the VoiceAttack action configured?

mkeymont

  • Guest
Re: send cURL requests via the windows command prompt...
« Reply #2 on: July 14, 2017, 06:50:30 PM »
I've actually learned some more since starting this. Out of curiosity I tried using VA to open cmd.exe, then copy the curl request to the clipboard, then paste the clipboard to the cmd.exe window via Ctrl+V keypress, then an Enter keypress.

When I do it this way, I get the Malformed JSON error.

There's something going on in the journey from VA to the clipboard. It looks right to me in the cmd.exe window once it pastes, but there's something off with it. I verified this by copying the request to the clipboard outside of VA, pasting and running and it works. Once I run the command via VA, the clipboard gets overwritten and the command fails again. The strange thing is that even manually pasting the clipboard back into the cmd.exe window fails until I re-copy the request from the original source.

Something's being changed...

I'll try writing a batch file next...

mkeymont

  • Guest
Re: send cURL requests via the windows command prompt...
« Reply #3 on: July 14, 2017, 07:08:39 PM »
The batch file works... maybe I can write batch files on the fly, but there's got to be a better way. I have a bunch of tasks that rely on sending web services requests, serial commands, UDP commands etc.

I'll keep plugging away over the weekend. If you are in contact with the dev, I might be able to pay for added functionality if it's not too unreasonable...

Thanks!

Antrys

  • Newbie
  • *
  • Posts: 22
Re: send cURL requests via the windows command prompt...
« Reply #4 on: July 15, 2017, 07:28:12 PM »
Just throwing straws here....
Are you using Quotes in lengthy Command line commands with spaces/characters?

Example:
program.exe "-t this is the parameter i want to pass all in quotes"

I ran into an issue like that a while back.
There's that thread:
http://voiceattack.com/smf/index.php?topic=1266.msg6181#msg6181

mkeymont

  • Guest
Re: send cURL requests via the windows command prompt...
« Reply #5 on: July 16, 2017, 07:27:12 AM »
I'll give that a shot, thanks!