Error using Invoke Web Service

Options

URL: https://api.smartsheet.com/2.0/workspaces
Method: POST
Accept: Application/json
Custom Headers: Authorization: Bearer %my API Code% Conent-Type: application/json
Content Type: Application/json
Request body: %RequestBody%
Save response: Get text into variable (for web pages)
Variables produced WebServiceREsponseHeaders CreateWorkspaceResponse StatusCode

In my display message for RequestBody I get this response

"{""name"":""" & WorkspaceName & """}"

it just stops on the Invoke Web Service

Any help would be appreciated.

Answers

  • Sorry my Set Variable is also set to RequestBody Value:

  • My set variable is set to "{""name"":""" & WorkspaceName & """}"

  • SSFeatures
    SSFeatures ✭✭✭✭✭✭

    Hi @DawnDean,

    Are you using Powershell to invoke the web request? You mentioned "Invoke Web Service", is this the "Invoke-WebRequest" function used in Powershell?

    I noticed that you have a typo in this line:

    Custom Headers: Authorization: Bearer %my API Code% Conent-Type: application/json
    

    "Conent-Type" should be "Content-Type"

    Also, can you show us what the variables show for "CreateWorkspaceResponse" and "StatusCode". These will probably tell us exactly what the problem is.

    Best!

    Nathan Braun (Founder of SSFeatures) (nathan@ssfeatures.com) (LinkedIn)

    SSFeatures makes Smartsheet way easier to use and it saves you hours of work every week. It adds essential features into Smartsheet to save you time. For example: — Auto Sorting — Sorting with Filters — Report PDF Generation — Copy and Paste Conditional Formats — Copy and Paste Automation Workflows — Column Manager — and so many more.

  • We Don't have the enterprise version of Worksheet, therefore I am trying to through Power Automate Desktop (not premium) to create workspaces and copy the folder structure and contents of the folders to the workspaces.

    That was a typo when I was entering in the comments, as it wont let me copy/paste it is spelt correctly as Content-Type - Great spot though.

    This is what my script currently looks like or the part which is erroring - thank you for taking the time to look at this. Greatly appreciated.

    image.png
  • Set Variable WorkspaceName value is set to %CurrentWorkspace['Workspace Name']% I have tried putting in " but when I save it it changes it to '

  • SSFeatures
    SSFeatures ✭✭✭✭✭✭

    @DawnDean Thanks for providing that screenshot, it's super helpful!

    In your initial post, you mentioned this:

    In my display message for RequestBody I get this response

    "{""name"":""" & WorkspaceName & """}"

    When you're setting the RequestBody variable, it seems like Power Automate is interpreting that string literally, instead of replacing it with the actual variable name. We want the request body to be something like:

    "{"name": "Workspace Name"}"
    

    In other words, we want Power Automate to use the variable named WorkspaceName in the body. I found this video: https://www.youtube.com/watch?v=0S_QgIOvB7c&t=428s

    And I think we need to use percent signs around the variable name so that power automate will interpret it as an actual variable. Try setting the RequestBody to something like this:

    "{"name": "%WorkspaceName%"}"
    

    Also, does Power Automate say anything when it fails on the "Invoke Web Service" step?

    Nathan Braun (Founder of SSFeatures) (nathan@ssfeatures.com) (LinkedIn)

    SSFeatures makes Smartsheet way easier to use and it saves you hours of work every week. It adds essential features into Smartsheet to save you time. For example: — Auto Sorting — Sorting with Filters — Report PDF Generation — Copy and Paste Conditional Formats — Copy and Paste Automation Workflows — Column Manager — and so many more.

  • Hi Nathan, I tried what you suggested above, both ways and still get the below

    For my First Comment
    Final JSON I get {"name":"Test Area"}
    next message Final RequestBody I get "{""name"":""" & WorkspaceName & """}"
    Then for my RawAPI Response I get {
    "errorCode" : 1008,
    "message" : "Unable to parse request. The following error occurred: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: REST input; line: 1, column: 2]",
    "refId" : "lslkvn"
    }

  • I will take a look at the video - thank you

NEW Smartsheet API Documentation - bookmark the updated link! https://developers.smartsheet.com