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

mkeymont

  • Newbie
  • *
  • Posts: 4
send cURL requests via the windows command prompt...
« on: July 14, 2017, 03: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: 1013
  • RTFM
Re: send cURL requests via the windows command prompt...
« Reply #1 on: July 14, 2017, 05: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

  • Newbie
  • *
  • Posts: 4
Re: send cURL requests via the windows command prompt...
« Reply #2 on: July 14, 2017, 05: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

  • Newbie
  • *
  • Posts: 4
Re: send cURL requests via the windows command prompt...
« Reply #3 on: July 14, 2017, 06: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: 16
Re: send cURL requests via the windows command prompt...
« Reply #4 on: July 15, 2017, 06: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

  • Newbie
  • *
  • Posts: 4
Re: send cURL requests via the windows command prompt...
« Reply #5 on: July 16, 2017, 06:27:12 am »
I'll give that a shot, thanks!