Best answer

Invalid API Response: - Got a result missing the "id" property

  • 23 June 2020
  • 2 replies
  • 615 views

Userlevel 1

I’ve looked at the four responses on this issue but haven’t been able to get them to work. I’ve reviewed this GitHub entry and have a sense for what it wants me to do, but not how I should implement it.

My polling trigger API is trying to substitite my “_id” for the expected “id” element. Much like the other four posts on this problem have suggested.

const options = {
url: 'https://app.hiro.fm/api/products',
method: 'GET',
headers: {
'Authorization': `Bearer ${bundle.authData.token}`
},
params: {

}
}

return z.request(options).then((response) => {
response.throwForStatus();
const result = z.JSON.parse(response.content);
result.id = result._id;
return result;
});

/* Also tried this syntax but get the same error */
/*
return z.request(options).then((response) => {
response.throwForStatus();
const result = z.JSON.parse(response.content);
return [{
...result,
id: result._id,
},];
});
*/

My response array looks like this. See the _id I’m aiming for?

[
{
"artworkUrl": "https://hiro-fm.s3.amazonaws.com/static/artwork/default-art.jpg",
"releaseMode": 0,
"episodes": [
"5eee5aae0dc1ac00198589a5"
],
"_id": "5eee4d6b0dc1ac00198589a1",
"name": "TEST",
"description": "TEST PRODUCT",
"instructorName": "",
"copyright": "",
"studentKeys": [],
"updatedAt": "2020-06-20T18:51:26.066Z",
"createdAt": "2020-06-20T17:54:51.892Z",
"__v": 1
}
]

And yet I still get the error

Invalid API Response: - Got a result missing the "id" property 

 

At this point I’m feeling deeply humbled and rather stupid for having spent so long trying to get this to work. Can ayone like @ForYourIT  or @ikbelkirasan or even @Danvers  show me what I’m doing wrong?

Thanks

-Colin

icon

Best answer by whiteca 23 June 2020, 20:09

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 1

Oops. I think I’ve solved this. Looks like a rookie error on my part. Basically mis-handled the response array.

Userlevel 7
Badge +8

Thanks for letting us know, @whiteca !