0

I am using the Text Analytics service (find the language) of the Azure portal and a Windows batch script with Curl which is sending JSON data:

The following Windows batch script using curl and the --data option works:

set data="{'documents':[{'id':1,'text':'your are my guest'}]}"

curl -X POST %endpoint% ^
-H "Content-Type: application/json" ^
--data %data% 

However, it does not work when I want to use the --data-urlencode option with the same code.

The output error is:

Request body must be present

I have tried many things (double quote, escape, and so on), but nothing works.

Some ideas?

Mofi
  • 46,139
  • 17
  • 80
  • 143
Trimok
  • 101
  • 3

1 Answers1

0

The solution was already described here

The trick is to use a ('Notepad++' UTF-8 without BOM) file, say data.txt, with the --data-binary option :

curl -X POST %endpoint% ^
-H "Content-Type: application/json" ^
--data-binary @data.txt 

Inside the file data.txt :

{'documents':[{'id':1,'text':'your are my guest'}]}

But it works with any language (chinese, hindi, etc...), so you don't have to encode anything. For instance, you could have use, in the data.txt file

{'documents':[{'id':2,'text':'大都会区有它自己的当地路边快餐口味'}]}
Trimok
  • 101
  • 3