WebAPI Cannot access property

Hi there,

I’m trying to set an image using an image URL from an API. Please see my blocks and the sample json (and url) below. I’ve tried a few different things but cannot seem to access the URL property. Could someone please advise what I’ve done wrong? I’ve followed a few YouTube videos and also answers on this forum for similar issues but without success. Thanks in advance

Filtered data with parameter:
[
{
“albumId”: 1,
“id”: 5,
“title”: “natus nisi omnis corporis facere molestiae rerum in”,
“url”: “https://via.placeholder.com/600/f66b97”,
“thumbnailUrl”: “https://via.placeholder.com/150/f66b97
}
]

Sample of raw data without parameter from https://jsonplaceholder.typicode.com/photos
[
{
“albumId”: 1,
“id”: 1,
“title”: “accusamus beatae ad facilis cum similique qui sunt”,
“url”: “https://via.placeholder.com/600/92c952”,
“thumbnailUrl”: “https://via.placeholder.com/150/92c952
},
{
“albumId”: 1,
“id”: 2,
“title”: “reprehenderit est deserunt velit ipsam”,
“url”: “https://via.placeholder.com/600/771796”,
“thumbnailUrl”: “https://via.placeholder.com/150/771796
},
{
“albumId”: 1,
“id”: 3,
“title”: “officia porro iure quia iusto qui ipsa ut modi”,
“url”: “https://via.placeholder.com/600/24f355”,
“thumbnailUrl”: “https://via.placeholder.com/150/24f355
},
{
“albumId”: 1,
“id”: 4,
“title”: “culpa odio esse rerum omnis laboriosam voluptate repudiandae”,
“url”: “https://via.placeholder.com/600/d32776”,
“thumbnailUrl”: “https://via.placeholder.com/150/d32776
},
{
“albumId”: 1,
“id”: 5,
“title”: “natus nisi omnis corporis facere molestiae rerum in”,
“url”: “https://via.placeholder.com/600/f66b97”,
“thumbnailUrl”: “https://via.placeholder.com/150/f66b97
},
{
“albumId”: 1,
“id”: 6,
“title”: “accusamus ea aliquid et amet sequi nemo”,
“url”: “https://via.placeholder.com/600/56a8c2”,
“thumbnailUrl”: “https://via.placeholder.com/150/56a8c2
},
{
“albumId”: 1,
“id”: 7,
“title”: “officia delectus consequatur vero aut veniam explicabo molestias”,
“url”: “https://via.placeholder.com/600/b0f7cc”,
“thumbnailUrl”: “https://via.placeholder.com/150/b0f7cc
}
]

Hi, @chrisanderson1006tt9! :wave:

This URL doesn’t seem to work for me. instead, this worked - https://jsonplaceholder.typicode.com/photos

Your code seems correct, but the URL does not.

Thanks! :blush:

2 Likes

Thanks @kartik14, I’ve just tried the URL’s again and they seem to be fine for me in the app. (perhaps I’ve copied it incorrectly just in the message, sorry?) To confirm, I can even get the JSON response to be set as the text in the label but I struggle after I convert it to become an object. As a test, I’ve been setting label1 to be the output of whatever I try just to read what it says in plain English. At the minute, it’s showing as “Undefined” although I’ve had it showing a single bracked “[” a double bracket “[]” and “Object object”, I cannot get to the value of the URL property.

I’m using a list block because the JSON response starts with [ but I’m still unable to get passe “Undefined”.

Any help or examples would be really appreciated! Thanks again

1 Like

Hi, @chrisanderson1006tt9! :wave:

Since you are saying that you can even make the response display on a label, can you please show us a screenshot of the your screen including the label?
It would help me get how the response starts.

Can you specify which ones? The one which you included in your first post, which had ?id= …? Because that doesn’t seem to work for me…

Thanks! :blush:

@kartik14 ah you’re right! The url’s with parameters don’t seem to be working on https://jsonplaceholder.typicode.com/ anymore!!! I’ll find another example to test my code on. Thank you for checking and responding so quickly.

1 Like

Hey @kartik14 ,

Sorry to bug you again :slight_smile: but I’m still unable to get this working, even with a working URL and response now. So here’s how it looks:

This is the URL being called: https://jsonplaceholder.typicode.com/comments?id=1
And this is the response:
[
{
“postId”: 1,
“id”: 1,
“name”: “id labore ex et quam laborum”,
“email”: “Eliseo@gardner.biz”,
“body”: “laudantium enim quasi est quidem magnam voluptate ipsam eos\ntempora quo necessitatibus\ndolor quam autem quasi\nreiciendis et nam sapiente accusantium”
}
]

I know the URL works as I can set the text of the label to just be the raw response and this works every time. But…

When the blocks are like this, the text of the label becomes “undefined”

When the blocks are like this, the text of the label does not change

I’ve tried replacing the get property “email” with a string block and typing in ‘email’, changing the list number/counter to 0 and 2 (in case there is an index issue) and a few other variations but I do not know how to access the property of an object.

Please could you advise what I’ve done wrong and how I can debug this (to help myself) so that I can get the object property value and use lists correctly with the API call?

Thanks in advance

PS. As requested, screenshot of response in app and blocks if I just sent the label text to be the response