<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error Code 40103 when using variables in parameters in APIs</title>
    <link>https://community.cisco.com/t5/apis/error-code-40103-when-using-variables-in-parameters/m-p/4879021#M225</link>
    <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;For those interested, I found the answer to my question here: &lt;A href="https://github.com/postmanlabs/postman-app-support/issues/6078" rel="noopener nofollow ugc"&gt;https://github.com/postmanlabs/postman-app-support/issues/6078&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Based on what I found out from this discussion, I made the following change to the Pre-Request Script and that way it works:&lt;/P&gt;
&lt;P&gt;before: let QUERY = URL_OBJECT.getQueryString();&lt;BR /&gt;
after: let QUERY = pm.variables.replaceIn(URL_OBJECT.getQueryString());&lt;/P&gt;
&lt;P&gt;Cheers&lt;BR /&gt;
Patrick&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 19 Oct 2022 15:44:12 GMT</pubDate>
    <dc:creator>patander</dc:creator>
    <dc:date>2022-10-19T15:44:12Z</dc:date>
    <item>
      <title>Error Code 40103 when using variables in parameters</title>
      <link>https://community.cisco.com/t5/apis/error-code-40103-when-using-variables-in-parameters/m-p/4879020#M224</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Hello Team&lt;/P&gt;
&lt;P&gt;I am running into the following issue using the Duo Admin API with Postman. When I run a GET request such as the following, I get an HTTP status code of 200 and a valid response.&lt;/P&gt;
&lt;P&gt;https://{{duo-API-HOST}}/admin/v1/users?username=xxx.yyy&lt;/P&gt;
&lt;P&gt;When instead of the actual username I use a variable in the request URL, which resolves to the same username (when hovering over with the mouse, as seen in the following screenshot)&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="2X_0_027914194dadd289bc01f6341bbc8d0db56a7a6c.png" style="width: 626px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/191249i718829BAB6D04492/image-size/large?v=v2&amp;amp;px=999" role="button" title="2X_0_027914194dadd289bc01f6341bbc8d0db56a7a6c.png" alt="2X_0_027914194dadd289bc01f6341bbc8d0db56a7a6c.png" /&gt;&lt;/span&gt;&lt;BR /&gt;
I get the following error:&lt;BR /&gt;
code: 40103&lt;BR /&gt;
message: Invalid signature in request credentials&lt;/P&gt;
&lt;P&gt;I am confused as to why one request with the username value works and the same request with the identical username passed as a variable value does not.&lt;/P&gt;
&lt;P&gt;Is this a Postman-specific issue? I am using the Pre-Request Script at the end of this post. Could it be that the reason for the invalid signatures is that the “params” used for construction of the signature do not actually use the resolved key=value pair (i.e. username=xxx.yyy) but the unresolved key=value pair (such as username={{username}})?&lt;/P&gt;
&lt;P&gt;Thanks in advance for you help!&lt;/P&gt;
&lt;P&gt;Best regards&lt;BR /&gt;
Patrick&lt;/P&gt;
&lt;P&gt;######################################################################&lt;BR /&gt;
let pc = require(‘postman-collection’);&lt;BR /&gt;
let cryptoJS = require(‘crypto-js’);&lt;BR /&gt;
let moment = require(‘moment’);&lt;/P&gt;
&lt;P&gt;let DATE = (moment().format(“ddd, DD MMM YYYY HH:mm:ss ZZ”));&lt;BR /&gt;
pm.environment.set(“duo-DATE”, DATE)&lt;/P&gt;
&lt;P&gt;let METHOD = request.method;&lt;/P&gt;
&lt;P&gt;let URL_OBJECT = new pc.Url(request.url);&lt;/P&gt;
&lt;P&gt;//HOST is retrieved from the environment variable itself, since parsing the hostname using&lt;BR /&gt;
//postman-collection’s URL object will just give you the variable name.&lt;BR /&gt;
let HOST = pm.environment.get(“duo-API-HOST”)&lt;/P&gt;
&lt;P&gt;let PATH = URL_OBJECT.getPath();&lt;BR /&gt;
let QUERY = URL_OBJECT.getQueryString();&lt;/P&gt;
&lt;P&gt;let HMAC_STRING = DATE + “\n”&lt;BR /&gt;
+ METHOD + “\n”&lt;BR /&gt;
+ HOST + “\n”&lt;BR /&gt;
+ PATH + “\n”&lt;BR /&gt;
+ QUERY&lt;/P&gt;
&lt;P&gt;let HMACd = cryptoJS.HmacSHA1(HMAC_STRING, pm.environment.get(“admin-skey”)).toString();&lt;/P&gt;
&lt;P&gt;pm.environment.set(“duo-admin-HMAC”, HMACd)&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 13 Oct 2022 09:55:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/error-code-40103-when-using-variables-in-parameters/m-p/4879020#M224</guid>
      <dc:creator>patander</dc:creator>
      <dc:date>2022-10-13T09:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Error Code 40103 when using variables in parameters</title>
      <link>https://community.cisco.com/t5/apis/error-code-40103-when-using-variables-in-parameters/m-p/4879021#M225</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;For those interested, I found the answer to my question here: &lt;A href="https://github.com/postmanlabs/postman-app-support/issues/6078" rel="noopener nofollow ugc"&gt;https://github.com/postmanlabs/postman-app-support/issues/6078&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Based on what I found out from this discussion, I made the following change to the Pre-Request Script and that way it works:&lt;/P&gt;
&lt;P&gt;before: let QUERY = URL_OBJECT.getQueryString();&lt;BR /&gt;
after: let QUERY = pm.variables.replaceIn(URL_OBJECT.getQueryString());&lt;/P&gt;
&lt;P&gt;Cheers&lt;BR /&gt;
Patrick&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Oct 2022 15:44:12 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/error-code-40103-when-using-variables-in-parameters/m-p/4879021#M225</guid>
      <dc:creator>patander</dc:creator>
      <dc:date>2022-10-19T15:44:12Z</dc:date>
    </item>
  </channel>
</rss>

