[GastForen Programmierung/Entwicklung AppleScript

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste

AppleScript für den DeepL Überstetzer (HTTP Request API)?

EinNeuling
Beiträge gesamt: 7

11. Dez 2018, 13:42
Bewertung:

gelesen: 9832

Beitrag als Lesezeichen
Hilft diese FAQ-Info irgendwie weiter (vgl. https://www.deepl.com/pro-faq.html)?

Zitat How do I send a translation request as a POST request?

In a POST request, you do not send the data in the URL, but rather as data in the body of the request. There exist libraries for most programming languages to support the easy sending of POST requests.

However, if you have to create a POST request yourself, you should consider the following points:

1. Use POST as the request method.
2. Set the Content-Type request header to application/x-www-form-urlencoded.
3. Set the Content-Length request header to the number of bytes in the request body.
4. Insert your translation request parameters into the request body. The parameters should be URL-encoded using the UTF-8 character set. In other words, the body looks exactly like the query part of the equivalent GET-request (the characters after the question mark of a GET-request).
5. Use the same URL as for GET-requests, but without parameters, i.e. https://api.deepl.com/v2/translate.

The request https://api.deepl.com/v2/translate?auth_key=00000000-0000-0000-0000-000000000000&text=This%20is%20a%20Test.&target_lang=EN should look like this as a POST request:
Code
POST /v2/translate HTTP/1.1 
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: 87

auth_key=00000000-0000-0000-0000-000000000000&text=This%20is%20a%20Test.&target_lang=EN



(Dieser Beitrag wurde von EinNeuling am 11. Dez 2018, 13:44 geändert)
Änderungsverlauf:
Beitrag geändert von EinNeuling (Novice) am 11. Dez 2018, 13:44