Page 1 of 1

How to use tsNetPostSync (Solved)

Posted: Fri Jun 21, 2019 11:11 am
by mrcoollion
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...