PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → JSON array not allowed in HTTP post content
JSON array not allowed in HTTP post content
Débuté par Jim, 11 avr. 2025 19:25 - 1 réponse
Posté le 11 avril 2025 - 19:25
We keep getting this syntax error although it is valid.
We are wondering if it is a WINDEV bug. WINDEV won't allow an array here.
We want to use this in a website that requires an array. beebotte.com

MyRequest..ContentType = "application/json"
MyRequest..Content = [
{
"library": {
"name": "City Central Library",
"books": [
{
"id": "book1",
"title": "To Kill a Mockingbird",
"author": "Harper Lee",
"year": 1960
},
{
"id": "book2",
"title": "1984",
"author": "George Orwell",
"year": 1949
}
]
}
}
]

Thanks
Jim
Posté le 21 avril 2025 - 13:29
Jim a écrit :
We keep getting this syntax error although it is valid.
We are wondering if it is a WINDEV bug. WINDEV won't allow an array here.
We want to use this in a website that requires an array. beebotte.com

MyRequest..ContentType = "application/json"
MyRequest..Content = [
{
"library": {
"name": "City Central Library",
"books": [
{
"id": "book1",
"title": "To Kill a Mockingbird",
"author": "Harper Lee",
"year": 1960
},
{
"id": "book2",
"title": "1984",
"author": "George Orwell",
"year": 1949
}
]
}
}
]

Thanks
Jim


Make use of backticks to declare the variable see (https://doc.windev.com/en-US/…)

Multiline string literal with backticks ( ` )

MyRequest.Content = `
{
"library": {
"name": "City Central Library",
"books": [
{
"id": "book1",
"title": "To Kill a Mockingbird",
"author": "Harper Lee",
"year": 1960
},
{
"id": "book2",
"title": "1984",
"author": "George Orwell",
"year": 1949
}
]
}
}
`