How to use tsNetPostSync (Solved)

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

How to use tsNetPostSync (Solved)

Post by mrcoollion » Fri Jun 21, 2019 11:11 am

Hello all magnificent LC devs,

I am working on a translation application And got stuck on implementing Google translation method. I've got Microsoft, RapidAPI and Yandex running with tsNetGetSync . Now I am trying to get Google translate to work with tsNetPostSync according with help of the google API example. The example is shown below but I cannot get it to work. Of coarse I have looked at LC examples like http://lessons.livecode.com/m/4071/l/69 ... -callbacks

Google API example

Code: Select all

POST https://translation.googleapis.com/language/translate/v2?key={YOUR_API_KEY}
 
{
 "source": "en",
 "target": "nl",
 "q": [
  "This is my text"
 ]
}
 
The tsNetPostSync request syntax from the dictionary is:

Code: Select all

 tsNetPostSync(pURL, xHeaders, pPostData, rOutHeaders, rResult, rBytes, [pSettings])
I have filled

Code: Select all

https://translation.googleapis.com/language/translate/v2?key={YOUR_API_KEY}
into the variable pURL but i have no clue on how to work the body part into tsNetPostSync . I keep getting error 400 (Bad request) :cry:

Can anybody help me on this?

Regards,
Paul (mrcoollion)

Addendum:
I have got it working with a get command and putting the parameter into the request URL...

Post Reply

Return to “Talking LiveCode”