Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to send nested json headers?

46 views
Skip to first unread message

Adrien

unread,
Dec 17, 2024, 8:01:58 AM12/17/24
to Automate for Android
Hello.
I'm trying tog get info from http.

Everything works fine in Linux with curl. However, I can't achieve the same thing in automate "http request" .
I have a specific header that I'm not able to send (working fine with curl). 
The header in curl is something like :
-H 'aaaaaa: {"bbbb" :"cccc", "ddddd" :"{\"eeeeee\":\"fffffff\", \"ggggggg\":\"hhhhh\"}", "iiiii" :""} '

I tried escaping double quotes, using jsonEncode....
Nothing is working.

How do I send a header like this one?

Thanks!

Henrik "The Developer" Lindqvist

unread,
Dec 17, 2024, 11:15:18 AM12/17/24
to Automate for Android
Just use the jsonEncode function, try:
  • Request headers= {"aaaaaa": jsonEncode({"bbbb":"cccc", "ddddd":{"eeeeee":"fffffff", "ggggggg":"hhhhh"}, "iiiii":""})}

Adrien

unread,
Jan 8, 2025, 7:53:07 AMJan 8
to Automate for Android
The solution was to use "\{" to "Avoid interpretation of left curly-bracket as start of a string interpolation"

Request headers={"aaaaa": "\{\"bbb\": \"ccc\", \"ddd\" : \"\{\\\"eee\\\":\\\"fff\\\", \\\"ggg\\\":\\\"hhh\\\"}\", \"iii\":\"jjj\"}"}
Reply all
Reply to author
Forward
0 new messages