<?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: testing API in Powershell: &amp;quot;expected null, got value&amp;quot; in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/testing-API-in-Powershell-quot-expected-null-got-value-quot/m-p/200020#M9344</link>
    <description>&lt;P&gt;&lt;EM&gt;"The simplest solution in this case is probably just to change your "{}" to "null"."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;yes it is:&lt;BR /&gt;$data = "null";&lt;/P&gt;</description>
    <pubDate>Sat, 31 Dec 2016 01:03:28 GMT</pubDate>
    <dc:creator>axew3</dc:creator>
    <dc:date>2016-12-31T01:03:28Z</dc:date>
    <item>
      <title>testing API in Powershell: "expected null, got value"</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/testing-API-in-Powershell-quot-expected-null-got-value-quot/m-p/199926#M9339</link>
      <description>&lt;P&gt;After looking through posts as well as the .ps1 files being used in the AD sync tool, I was trying to run some simple data gathering api calls to get a feel for things however when I try to run a 'get_current_user' I get an error that it was expecting a null body but received data. &amp;nbsp;If I forgoe adding a body property, it states&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Invoke-RestMethod : Error in call to API function "users/get_current_account": request body: could not decode input as JSON".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$authorization = "Bearer [redacted]"&lt;BR /&gt;$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"&lt;BR /&gt;$headers.Add("Authorization", $authorization)&lt;BR /&gt;$ContentType = 'application/json;charset=utf-8'&lt;BR /&gt;$uri = "&lt;A href="https://api.dropboxapi.com/2/users/get_current_account" target="_blank"&gt;https://api.dropboxapi.com/2/users/get_current_account&lt;/A&gt;"&lt;BR /&gt;$json = "{}"&lt;BR /&gt;$body = ([System.Text.Encoding]::UTF8.GetBytes($json))&lt;BR /&gt;Invoke-RestMethod -Uri $uri -Headers $headers -Body $body -ContentType $ContentType -Method post&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Invoke-RestMethod : Error in call to API function "users/get_current_account": request body: expected null, got value&lt;BR /&gt;At line:8 char:1&lt;BR /&gt;+ Invoke-RestMethod -Uri $uri -Headers $headers -Body $body -ContentTyp ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException&lt;BR /&gt;+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:27:15 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/testing-API-in-Powershell-quot-expected-null-got-value-quot/m-p/199926#M9339</guid>
      <dc:creator>Jon P.4</dc:creator>
      <dc:date>2019-05-29T09:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: testing API in Powershell: "expected null, got value"</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/testing-API-in-Powershell-quot-expected-null-got-value-quot/m-p/199977#M9340</link>
      <description>&lt;P&gt;When making an API call like this that takes no parameters, you can do it one of two ways:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Don't supply any request body, and accordingly omit the Content-Type request header.&lt;/LI&gt;
&lt;LI&gt;Supply just "null" as the request body, and submit the Content-Type request header as "application/json".&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you have it, you're submitting a non-null JSON body, which is unexpected for this call, as it doesn't expect any parameters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, apologies, this is confusing in this case, as you're only supplying an empty dictionary, but as it's built right now, the API won't accept that. The simplest solution in this case is probably just to change your "{}" to "null".&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2016 15:33:44 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/testing-API-in-Powershell-quot-expected-null-got-value-quot/m-p/199977#M9340</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-12-30T15:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: testing API in Powershell: "expected null, got value"</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/testing-API-in-Powershell-quot-expected-null-got-value-quot/m-p/199988#M9342</link>
      <description>&lt;P&gt;Hey Greg,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option 1 did not seem to work for me:&lt;/P&gt;&lt;PRE&gt; Bad HTTP "Content-Type" header: "application/x-www-form-urlencoded".  Expecting one of "application/json"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option 2 however did work properly. &amp;nbsp;I thought I had tried that before but apparently was sending&lt;/P&gt;&lt;PRE&gt;$json = $null &lt;/PRE&gt;&lt;P&gt;instead of&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$json = "null"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the assistance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit with full code of what worked:&lt;/P&gt;&lt;PRE&gt;$authorization = "Bearer [redacted auth key]"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", $authorization)
$ContentType = 'application/json'
$uri = "https://api.dropboxapi.com/2/users/get_current_account"
$json = "null"
$body = ([System.Text.Encoding]::UTF8.GetBytes($json))
Invoke-RestMethod -Uri $uri -Headers $headers -Method post -body $body -ContentType $ContentType&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Dec 2016 17:42:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/testing-API-in-Powershell-quot-expected-null-got-value-quot/m-p/199988#M9342</guid>
      <dc:creator>Jon P.4</dc:creator>
      <dc:date>2016-12-30T17:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: testing API in Powershell: "expected null, got value"</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/testing-API-in-Powershell-quot-expected-null-got-value-quot/m-p/200020#M9344</link>
      <description>&lt;P&gt;&lt;EM&gt;"The simplest solution in this case is probably just to change your "{}" to "null"."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;yes it is:&lt;BR /&gt;$data = "null";&lt;/P&gt;</description>
      <pubDate>Sat, 31 Dec 2016 01:03:28 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/testing-API-in-Powershell-quot-expected-null-got-value-quot/m-p/200020#M9344</guid>
      <dc:creator>axew3</dc:creator>
      <dc:date>2016-12-31T01:03:28Z</dc:date>
    </item>
  </channel>
</rss>

