<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: NG</title>
    <description>The latest articles on DEV Community by NG (@ngregistrations).</description>
    <link>https://dev.to/ngregistrations</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2488449%2Fe36a93e2-6e3b-455e-8385-b25e463d8304.png</url>
      <title>DEV Community: NG</title>
      <link>https://dev.to/ngregistrations</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ngregistrations"/>
    <language>en</language>
    <item>
      <title>Error: cannot mix str with (non-str) arguments</title>
      <dc:creator>NG</dc:creator>
      <pubDate>Thu, 05 Dec 2024 22:04:09 +0000</pubDate>
      <link>https://dev.to/ngregistrations/error-cannot-mix-str-with-non-str-arguments-4o64</link>
      <guid>https://dev.to/ngregistrations/error-cannot-mix-str-with-non-str-arguments-4o64</guid>
      <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpupjfqbb164ogwvd3c2w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpupjfqbb164ogwvd3c2w.png" alt="Image description" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the function definition&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# 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()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I tested the URI with Postman, to confirm it is ok, and it is.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8x1lpmqgwhgkvfun2g5b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8x1lpmqgwhgkvfun2g5b.png" alt="Image description" width="800" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;URI = (f"https://dev.azure.com/{Org}/{Prj}/_apis/git/repositories/{r['id']}/refs")
refsDetails = (requests.get(URI, auth=userauth)).json()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, I do not know why I am getting that error when using the function, I tried to put &lt;code&gt;str(RepoID)&lt;/code&gt;, did not work.&lt;/p&gt;

&lt;p&gt;Any help would be greatly appreciated.&lt;/p&gt;

&lt;p&gt;Thanks.&lt;br&gt;
NG&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Python response.json() fields starting with "_"</title>
      <dc:creator>NG</dc:creator>
      <pubDate>Tue, 26 Nov 2024 21:16:54 +0000</pubDate>
      <link>https://dev.to/ngregistrations/python-responsejson-fields-starting-with--4j1e</link>
      <guid>https://dev.to/ngregistrations/python-responsejson-fields-starting-with--4j1e</guid>
      <description>&lt;p&gt;Hi everyone..&lt;/p&gt;

&lt;p&gt;Wonder if any can point me in the right direction...&lt;/p&gt;

&lt;p&gt;I define a function in the views.py file to get data from an API... but in the json that is returned, some of the fields start with and underscore.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi6f8cdk019mb5em4miud.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi6f8cdk019mb5em4miud.png" alt="Image description" width="532" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is my function:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff8llu5i9cndaw0yeumdl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff8llu5i9cndaw0yeumdl.png" alt="Image description" width="800" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, I am outputing this data in a webpage, when I loop through the results, it works... by calling the objects&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;response.results
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But when I try&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;response._link
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then it fails.  Here is how it looks like in the code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhwnaaxnv3qsesda5r6mv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhwnaaxnv3qsesda5r6mv.png" alt="Image description" width="800" height="617"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The error I get is : Variables and attributes may not begin with underscores: 'response._links.next'&lt;/p&gt;

&lt;p&gt;I tried response[_link][next]  did not work.&lt;br&gt;
I need to capture that NEXT, as it is the pagination offered by this API, so I can continue to get all the records.&lt;/p&gt;

&lt;p&gt;Any help will be appreciated.&lt;br&gt;
Thanks.&lt;br&gt;
NG&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
