Basic API consuming

Hi team.

I tried following Benjamin Fadina's instructions on consuming REST service from Pixabay. PicturePuller solution.
The original worked as supposed (thanks Benjamin!) but I wanted to see if I could do the same in the latest Radzen version.
Without writing FetchImages() Task but using the REST API as a data source from the Radzen IDE. i.e, scaffolding the REST instead of defining it in C#.

Documentaton: Pixabay API Documentation .
I've tried both for just pictures, which lands on the root ( https://pixabay.com/api/?key=xxxxxxxxxxxxxxx ) and \videos ( https://pixabay.com/api/videos/?key=xxxxxxxxxxxxxxx )

  • to no avail. Speaking of which, what do we put in Data Source -> ... -> Resource, when the final endpoint is the root base. Just "/" , which would double the backslashes?
    In the Pixabay's pictures, the main endpoint is https://pixabay.com/api/, and the Resource is the same - no "subfolder" there. Putting https://pixabay.com/api/?key=xxxxxxxxxxxxxxx
    right in the browser shows up data.
    Also, I hope I'm using correctly "in Header" for the API Key authorization, and not "in Query string". Although I tried both, seemed to give me the same result ...
    The record shows up, the fields too but no data displayed in the grid, only the column's headers.
    With the debugging info in the Radzen's output:
    ==
    Dotnet: fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
    Unhandled exception in circuit 'lPEy7aMgb8XYUokSZMjIAodOLNg8kkP25YwkIzYxfV4'.
    System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
    ==

Fairly self-explanatory. I know I haven't constructed the request correctly, but I'm not sure where I'm making mistake(s). If I'm not going deep enough in the api's levels.
No filtering query with the "q=yellow+flowers" concatenation, just the basic show it all.
I tried both :5001 and :5000 , https and http.

Snapshots attached.

Thanks in advance,
Sime

PS Spotify example works well, but it's an OAuth, and has "subfolders" for endpoints.




Sorry about this, replying to myself so I can upload the other snapshots 2/3 ( five is the limit )




3/3




You can probably specify https://pixabay.com as the ENDPOINT and then use /api for the resource path.

Also according to their documentation the key parameter is part of the query and not a header:

https://pixabay.com/api/?key={ KEY }&q=yellow+flowers&image_type=photo

Thanks Atanas! I will try that. I didn't know I can arbitrarily parse the endpoint and resource path like that. I guess at the end it comes to one query string anyway. And "nothing" is not accepted as a resource path.

No luck for me with this mini-project :frowning:
I'm doing something wrong, and I don't know what it is.
Strange thing: even if I put an incorrect X-API-Key in the data source definition I get
"Response Status Code of 400, Bad Request", or somewhat along that line.
Also, I'm not sure how to handle the ? between the Slash and "key".
Straight in the browser works w/o any problem:
https://pixabay.com/api/?key=18547591-da54c8241f51c161d61e3dcaa

I suggest you debug the API call and see what full the server response is.

Will do that - thanks.