DEV Community

NG
NG

Posted on

Error: cannot mix str with (non-str) arguments

Hello everyone,

I have a function that connects to an API and get data and needs 3 parameters, all string, but one of them is a GUID. Here are the values I pass to the function from the output of the Debug console.

Image description

Here is the function definition

# Get all branches in a repo
def GetRepoBranches(Org, Prj, RepoID):
    URI = (f"https://dev.azure.com/{Org}/{Prj}/_apis/git/repositories/{RepoID}/refs")
    return (requests.get(URI, userauth)).json()
Enter fullscreen mode Exit fullscreen mode

I tested the URI with Postman, to confirm it is ok, and it is.

Image description

The interesting thing is, when I run the following code without using the function, and passing the same values when building the URI, it works ok:

URI = (f"https://dev.azure.com/{Org}/{Prj}/_apis/git/repositories/{r['id']}/refs")
refsDetails = (requests.get(URI, auth=userauth)).json()
Enter fullscreen mode Exit fullscreen mode

So, I do not know why I am getting that error when using the function, I tried to put str(RepoID), did not work.

Any help would be greatly appreciated.

Thanks.
NG

Top comments (0)