Sorting Google sheets with an API call

Hi,
I’m trying to make an API call to sort a 4 column sheet with several sorting levels.

For some reason I keep getting an error: 400: INVALID_ARGUMENT - Invalid JSON payload received. Expected an object key or }.

here is a screen shot of the module:

This is the body:

This is the error screenshot:

Would appreciate your help :pray:

Hi @Danny_Shor

The request from api documentation is the structure of the body. Hence, the values of the parameters you have to change based on your data.

Please replace the variable SHEET_ID with your actual spreadsheet ID.

Also, to validate the json, you can paste you JSON in JSON formatter :point_down:
https://jsonformatter.curiousconcept.com/

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

2 Likes

Thanks @Msquare_Automation, I obviously checked with my SHEET_ID, but the formatter was a big help because it considered the indentation as spaces so that is why it failed.

No that it’s done, I’m facing a new error: 500: INTERNAL - Internal error encountered.
I can’t find the reason why.

If you have any ideas I’ll be happy to hear.

@Danny_Shor

It seems server found something against the request. Please check the request body

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

1 Like

Hi @Danny_Shor

This one worked for me - assuming there are 7 columns and that you want to sort column C and E and that you have a headers in the table.

Don’t forget to add the relevant sheetId.

{
  "requests": [
    {
      "sortRange": {
        "range": {
          "sheetId": "XXXXX",
          "startRowIndex": 1,
          "endRowIndex": 1000,
          "startColumnIndex": 0,
          "endColumnIndex": 7 
        },
        "sortSpecs": [
          {
            "dimensionIndex": 2,
            "sortOrder": "ASCENDING"
          },
          {
            "dimensionIndex": 4, 
            "sortOrder": "ASCENDING"
          }
        ]
      }
    }
  ]
}
2 Likes

Unfortunately still not working :frowning:
I checked the JSON in the https://jsonformatter.curiousconcept.com/ website - checks OK.
When running the automation is shows still error 500

here are the photos from Integromat debugger. se maybe what I have missed




Hi @Danny_Shor
It’s hard to analyze from the pictures - can you upload it as a code?

Maybe it’s related to the indentation.

I also received error 500 using the code to the left but everything was working with the code to the right:

1 Like

Hi, I managed to make it work.
Didn’t changed anything, just created the module in another make account and with another Google account, and switched it back to the original accounts.
The call any body didn’t changed :man_shrugging:

2 Likes