title: Using GoPhish API in Powershell to Launch Campaigns
body: <p>currently i'm attempting to setup GoPhish to launch campaigns through a Windows PowerShell script using it's API. The issue that i'm running into that is i'm getting this error.</p>
  
  <pre><code>Invoke-WebRequest : { "message": "Invalid JSON structure", "success": false, "data": null }
  </code></pre>
  
  <p>The thing is I have triple checked my JSON structure and it doesn't show any errors in JSON formatting checkers. So my question is if there are any errors in the code I have below for actually pushing these campaigns via PowerShell.</p>
  
  <pre><code>$jsonString = @"
  {
     "name":"Test6",
     "template":{
        "name":"Test"
     },
     "url":"http://redacted",
     "page":{
        "name":"Test"
     },
     "smtp":{
        "name":"Test SMTP"
     },
     "launch_date":"2019-25-07T08:20:00+00:00",
     "send_by_date":null,
     "groups":{
        "name":"Test Group"
     }
  }
  "@
  
  Invoke-WebRequest -Uri https://redacted/api/campaigns/?api_key=redacted -Method POST -Body $jsonString
  </code></pre>
  
  <p>So if you see any errors in what I have an could help me out, that'd be awesome. The API documentation shows that it should be in this format</p>
  
  <pre><code>{
      "name":"CC Example Campaign",
      "template":{"name":"Example Template"},
      "url":"http://localhost",
      "page":{"name":"Example Landing Page"},
      "smtp":{"name":"Example Sending Profile"},
      "launch_date":"2018-10-08T16:20:00+00:00",
      "send_by_date":null,
      "groups":[{"name":"Example Group"}]
  }
  </code></pre>