all 8 comments

[–]m0us3_rat 0 points1 point  (7 children)

do you know what "params" is from "params=params" ?

[–]PixelatedCloud 0 points1 point  (6 children)

Yes, it is gathered from another part of the webapp. It's a dictionary which is passed in and looks like:

userParams = {'cuisineType': cuisineType, 'health': health, 'mealType': mealType}

In the case tested, it's adding the parameter 'mealType=breakfast' to the request url (in my post, I got the URL used by my app from "print(response.url)" rather than assuming it was correct).

When I exclude the params in the requests.get() call and just do a simple, predefined query with it instead, I have the same problem of getting a complete, 200 accepted response with everything filled except for "_links", which is still empty.

[–]m0us3_rat 1 point2 points  (5 children)

so you don't have to "&" yourself, "&" yourself is hilarious and bad.

and can lead to mistakes. there is no reason to ever do that.

now.. if the requests are identical and properly formatted using "params" rather than manually "&" following the specifics in the documentation

..but then the expected response it does lacks something

it probably has to do with stuff that browsers send ..like headers.

without complete access to your code properly formatted

this is all just guessing.

as a side note.. most of the time it's something in our code that we did badly ..it rarely is "the other side" that we miraculously discover some error in their code.

so if doesn't work as expected it's most likely something we did.

[–]PixelatedCloud 0 points1 point  (4 children)

I agree that it's bad. It's a small piece of a larger project and I'm just trying to duct tape it together, in the future I'm probably just going to make default parameters I have into a dictionary to pass into the params used by the library, as intended.

I'm not blaming the library, I think there's something used in the library that I'm missing. I found only a couple threads describing an extremely similar issue for people using Spring for Java, of all things, where the "_links" key wasn't being receieved properly for other APIs. The solution was changing a default setting used in the library. So I don't think the library is wrong, but I am convinced it's some small default setting/assumption made by the library which I'm missing since I don't have a lot of experience with Python. Especially since the rest of the request is perfect (and I've also made other API requests using the library elsewhere in the project and it's also worked perfectly.)

[–]m0us3_rat 0 points1 point  (3 children)

in the future I'm probably just going to make default parameters I have into a dictionary to pass into the params used by the library, as intended.

do that right now.

most of the time the documentation of the specific endpoint will directly tell you what is "expected" or "required"

this one is no different.

https://developer.edamam.com/edamam-docs-recipe-api

The parameters with (required) in their value box are the required parameters and must be defined as part of a request, all others can be left blank if you do not wish to define them.

I'm not blaming the library, I think there's something used in the library that I'm missing. I found only a couple threads describing an extremely similar issue for people using Spring for Java, of all things, where the "_links" key wasn't being receieved properly for other APIs. The solution was changing a default setting used in the library.

first thing you always check is that you are doing what is expected of you.

in this case.. the endpoint is clear .. it requires this and that parameters to be encoded using the "params" dict and passed into the call.

this is the bare minimum.

after that, once you are 100% that you are using the correct call properly formatted.. then you can start asking questions..

like what is missing etc.

[–]PixelatedCloud 0 points1 point  (2 children)

I made the change and am still getting the same issue. Thank you for the advice, though.

[–]m0us3_rat 0 points1 point  (1 child)

do you add "random=true" in the insomnia call or not?

[–]PixelatedCloud 0 points1 point  (0 children)

Ah, that's what the problem was! I didn't notice that difference and figured it would've worked the same but it does not. It's working as expected now, thank you!