title: Powershell Invoke-RestMethod
body: <p>I'm trying to create a powershell script to access DYN's API and perform checks/updates on DNS zones I use/test.  </p>
  
  <p>I'm following their API details and here's the first link, <a href="https://help.dyn.com/session-log-in/" rel="noreferrer">https://help.dyn.com/session-log-in/</a> </p>
  
  <p>Here's the beginning of the REST script I've put together:</p>
  
  <pre><code>$url = "https://api2.dynect.net/REST/Session/"
  $body = @{customer_name='mahcompany';user_name='mahname';password='mahpass'}
  Invoke-RestMethod -Method Post -Uri $url  -Body $body
  </code></pre>
  
  <p>This produces the following results:</p>
  
  <blockquote>
    <p>Invoke-RestMethod : The remote server returned an error: (406) Not Acceptable.
    At line:12 char:9
    + $test = Invoke-RestMethod -Method Post -Uri $url  -Body $body
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-> RestMethod], WebException
        + FullyQualifiedErrorId : 
    WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand</p>
  </blockquote>
  
  <p>This is supposed to be a JSON query according to the DYN information, and so I've tried sevveral other examples of DYN's using CURL as a basis:</p>
  
  <pre><code>$json = @"{"customer_name":"yourcustomer","user_name":"youruser","password":"yourpass"}' 
  </code></pre>
  
  <p>However this doesn't work either. </p>
  
  <p>Can anyone point me in the right direction here?  This can't be that crazy, I'm just trying to pass the parameters into a rest-method query string.   Any help would be very much appreciated at this point. </p>
  
  <p>-Sean</p>