Go REST
S

Getting a 422 error while making a post request

Sherwin Fernandes over 3 years ago 4673 views 3 replies

const res = await fetch(
https://gorest.co.in/public/v2/posts, {
headers: {
Authorization: Bearer ${API_TOKEN},
'Accept': 'application/json',
Content-Type: 'application/json'
}
}

Respose data says user must exist. It worked 2-3 times before

3 replies
Z
zeevy over 3 years ago

The user I'd used in the body should exists.

If the user is modified or added by someone else then you can't add posts to that user.

Please create or modify any user and use that user Id in payload

Р
Рома Тиманов over 3 years ago

fetch('https://gorest.co.in/public/v2/users', {
method: 'POST',
body: JSON.stringify[{
name: Roman,
email: roman@veum.net,
gender: man,
status: active
}],
headers: {
Authorization: Bearer e142ed77beaafae6c253c95ebed2b3770a455e8fe2577e12956f1a227b7656e9,,
Content-Type: application/json
}
})

K
kutas over 3 years ago

fetch('https://gorest.co.in/public/v2/users', { method: 'POST', body: JSON.stringify[{ name: Roman, email: roman@veum.net, gender: man, status: active }], headers: { Authorization: Bearer e142ed77beaafae6c253c95ebed2b3770a455e8fe2577e12956f1a227b7656e9,, Content-Type: application/json } })

Your reply

Markdown supported