List to JSON for sending SMS

Welcome Forums General PowerShell Q&A List to JSON for sending SMS

Viewing 2 reply threads
  • Author
    Posts
    • #285115
      Participant
      Topics: 8
      Replies: 12
      Points: 120
      Rank: Participant

      Hi,

      I’m trying to add an SMS alert to a script using ClickSend however having an issue with getting powershell to output the required format in JSON i think, i get a response saying “The remote server returned an error: (400) Bad Request”

      I suspect the issue is me not correctly formating the body of the message inline with their docs here – https://developers.clicksend.com/docs/rest/v3/#ClickSend-v3-API-SMS

       

       

      Any help adjusting my script would be much appreciated.

      Regards,

      Jamie

      • This topic was modified 1 week, 2 days ago by JDobbsy1987.
      • This topic was modified 1 week, 2 days ago by JDobbsy1987.
      • This topic was modified 1 week, 2 days ago by JDobbsy1987.
      • This topic was modified 1 week, 2 days ago by JDobbsy1987. Reason: Code E
      • This topic was modified 1 week, 2 days ago by JDobbsy1987. Reason: Code Formatting
      • This topic was modified 1 week, 2 days ago by kvprasoon.
    • #285184
      Participant
      Topics: 5
      Replies: 253
      Points: 1,007
      Helping Hand
      Rank: Community Hero

      I have zero experience with this API, but all the examples I saw in the docs show the message property as an array.  That is the only difference I see in your json.  You might want to try that and see if it is the issue.  Pretty simple to do, just wrap your messages value in an array subexpression @().

       

       

    • #285226
      Participant
      Topics: 8
      Replies: 12
      Points: 120
      Rank: Participant

      Thank you so much, that worked!

      I can’t believe how close my code was all this time, i actually swapped @{ for @( and played with different variations of that etc but never tried them together, although i now see whats happening and how that works so thank you very much.

       

      – Jamie

Viewing 2 reply threads
  • You must be logged in to reply to this topic.