X
Xata2mo ago
Matthew

hi, why i can't insert record using

hi, why i can't insert record using fetch? function test() { const payload = { wallet_id: "string" }; const options = { method: 'POST', headers: { Authorization: 'Bearer key', 'Content-Type': 'application/json' }, body: payload }; try { const response = UrlFetchApp.fetch('linklink', options); Logger.log(response.getContentText()); } catch (e) { Logger.log("Error: " + e.message); } } and after null
No description
3 Replies
kostas
kostas2mo ago
I'm wondering if it is a serialization issue. Can you try placing the payload in the body directly along the lines:
const options = {
method: 'POST',
headers: {
Authorization: 'Bearer key',
'Content-Type': 'application/json'
},
body: '{"wallet_id":"string"}'
};
const options = {
method: 'POST',
headers: {
Authorization: 'Bearer key',
'Content-Type': 'application/json'
},
body: '{"wallet_id":"string"}'
};
Matthew
Matthew2mo ago
ok, i fixed that with 'method': 'post', idk why but fixed. So, how i can get one record where wallet_id = my value? U know?
kostas
kostas2mo ago
You would apply a filter in the body of your request such as:
const payload = {
"filter": {
"wallet_id": "my value"
}
}
const payload = {
"filter": {
"wallet_id": "my value"
}
}
And send that with a post request to the /query endpoint of your table. You can find an example here: https://xata.io/docs/sdk/filtering#exact-matching Switch the tab to JSON to see the raw HTTP request url endpoint and body content
Want results from more Discord servers?
Add your server