Python Forum
Error: cannot mix str with (non-str) arguments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error: cannot mix str with (non-str) arguments
#1
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. So I validated what data type is the GUID coming with, and it is "text", but still get the error about mixing data types. Here is what the debugger returned when validating the data types which also shows the error message.

   

is how I define the function inside my views.py file:

def GetRepoBranches(Org, Prj, RepoID):
URI = (f"https://dev.azure.com/{Org}/{Prj}/_apis/git/repositories/{RepoID}/refs")
return (requests.get(URI, userauth)).json()


To test the URI constructed in the function, I used PostMan and it worked ok (See attachment to view the whole URI).

   

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()


So, I do not know why I am getting that error when using the function. Any help would be greatly appreciated.

Thanks
NG
Larz60+ write Dec-11-2024, 05:58 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
Error: cannot mix str with (non-str) arguments - by ngregistrations - Dec-10-2024, 10:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given paulo79 1 3,704 Oct-17-2022, 06:29 PM
Last Post: paulo79
  invalid keyword arguments error sagpal 3 3,539 Jun-04-2020, 10:24 PM
Last Post: bowlofred
  Function / Arguments / Error Help Ghosty 8 6,038 Jul-01-2018, 10:35 AM
Last Post: buran
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 4,790 Mar-02-2017, 10:23 PM
Last Post: zivoni
  error: unrecognized arguments zafar202 2 50,344 Feb-08-2017, 02:50 PM
Last Post: zafar202

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020