J
jdajul
Ambitioniertes Mitglied
- 1
Hallo ich habe folgenden CURL Befehl:
$ curl -XPOST 'https://api.wit.ai/entities/favorite_city/values?v=20141022' \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{"value":"Paris",
"expressions":["Paris","City of Light","Capital of France"],
"metadata":"CITY_1234"}'
Wie kann ich den denn übersetzen?
Ich habe es wie folgt versucht:
Allerdings funktioniert das leider nicht - hat jemand ne Ahnung wieso?
$ curl -XPOST 'https://api.wit.ai/entities/favorite_city/values?v=20141022' \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{"value":"Paris",
"expressions":["Paris","City of Light","Capital of France"],
"metadata":"CITY_1234"}'
Wie kann ich den denn übersetzen?
Ich habe es wie folgt versucht:
Code:
try {
HttpURLConnection httpcon = (HttpURLConnection) ((new URL("https://api.wit.ai/entities/time/values?v=20141022").openConnection()));
httpcon.setRequestMethod("POST");
httpcon.setDoOutput(true);
httpcon.setRequestProperty("Content-Type", "application/json");
httpcon.setRequestProperty("Authorization", "Bearer $ MYTOKEN");
httpcon.connect();
final String toWriteOut = "{'value': test}";
final OutputStreamWriter osw = new OutputStreamWriter(httpcon.getOutputStream());
osw.write(toWriteOut);
osw.close();
}
catch (Exception e){
System.out.println("url post failed");
}
Allerdings funktioniert das leider nicht - hat jemand ne Ahnung wieso?
Zuletzt bearbeitet: