Jump to content
Server Maintenance This Week. ×

cURL transformation on FileMaker Pro 16


This topic is 2250 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

imageproxy.php?img=&key=b0a00e4a1cc52ac1

Hello,

I think I'm about to understand things around REST API and how to use them from my terminal when I see APIs documentation. I'm fighting a lot with the use of quotes when I want to use them from a FileMaker file. For example the following code works very well from my terminal  (it's an example that you can try from IBM watson):

(It's a text-to-speech service that provide a sound file made with the text you sent)

curl -X POST -u login:password \
--header "Content-Type: application/json" \
--header "Accept: audio/wav" \
--data "{\"text\":\"My name is Christophe\"} " \
--output hello_world.wav \
"https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize"

This works perfectly and the file is downloaded in my user folder

So I tried to translate all this in a FileMaker script like this:

Set Variable [ $File; Value:Test::FileToDownload ] // Test::FileToDownload is a container field

Set Variable [ $cURLOption; Value:"-X POST -u login:password

                     --header \"Content-Type: application/json\"

                      --header \"Accept: audio/wav\"

                      --data \"{\"text\":\"My name is Christophe\"}\"

                     --output @$File" ]

Set Variable [ $URL; Value:"https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize" ]

Insert from URL [ $Result; $URL; cURL options: $cURLOption ] [ Select; No dialog ]

The answer in $result is :

{
   "code_description": "Bad Request", 
   "code": 400, 
   "error": "Expecting object: line 1 column 1 (char 0)"
}

 

I don't know if I'm far away from finding (and understanding) the right way to do but if anybody has an idea, I would be really glad

Thanks in advance.

Christophe

 

Edited by katok
Link to comment
Share on other sites

This topic is 2250 days old. Please don't post here. Open a new topic instead.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.