NodeApiError: Your request is invalid or could not be processed by the service

I’m trying to add a worker to onfleet using new rows from a spreadsheet. It properly pulls the spreadsheet data and then errors out on the add worker step. does anyone have a recommended next step?

NodeApiError: Your request is invalid or could not be processed by the service

Interval / Start > Google Sheets (read sheet) > check if new row > Onfleet (create worker)

NodeApiError: Your request is invalid or could not be processed by the service

Hi @para_ops, I am sorry to hear you are having trouble.

It seems you have unfortunately not provided any of the data in question template here on the forum. The error would suggest you are simply sending invalid data to Onfleet, but without knowing how to reproduce this problem in the first place it’s hard to say.

My next step would be to narrow down the problem. Try processing only one item from your Sheet at a time. Does your logic fail for all items or just some of them? Then take it from there.

Hi @MutedJam, thanks for the quick reply. I just hardcoded the team field and it ran properly. is there a way to troubleshoot why the dynamic team ID field based on the new google sheet row doesnt work properly? To note … when toggling from expression to fixed … the proper team was already pre-selected … so something is working properly.

If it works with a hardcoded value the problem is likely with your expression @para_ops. Is there any change the team ID is not part of the incoming data on the node throwing the error? If so, you might be running into this problem here.

i think the expression data for team ID is flowing in properly because it populates in the field

The preview would would only show the first item. Is it available for all items? Which expression exactly are you using?

{{ $json[“Team_ID”] }}

Hm, this is looking good to me. Is this field available for all incoming items? Can you share your node and the JSON payload you are sending to it?

please instruct how to share node and JSON payload

Simply select the node on your canvas, then post it here on the forum. For the payload you can copy the JSON from the JSON view in n8n. You can of course redact any confidential values when doing so as long as you make sure the actual data structure remains intact.

node:

input json:

{
  "Name": "Redacted Name",
  "Onfleet_phone": "111-111-1111",
  "Team_ID": "redacted_team_id",
  "Display_Name": "Para - Redacted Name"
}

output json:

{
  "error": "NodeApiError: Your request is invalid or could not be processed by the service"
}
1 Like

Are you passing on only a single item to your Onfleet node? I am asking because n8n would use an array, so the first item of the input data would usually be a [:

Is the Team ID perhaps a numeric value, but OnFleet is expecting a string (or vice versa)? If so, can you try converting it (from numeric to string you could use an expression of {{ $json["Team_ID"].toString() }} for this).

yes i simplified the expression to one row of data to troubleshoot … the team ID is not numeric nor are they expecting it to be since there are special characters in there

Alright, it seems the " Team Names or IDs" field is typically pre-populated and comes with a dropdown. If you choose a valid value on your end (like your did when testing this with a hard-coded value) and then switch to “Expression”, how does the pre-populated expression provided by n8n look like? Does it differ from the value your are currently sending to the node in your expression?

the pre-populated expression provided by n8n matches the value I’m currently using

Hm, in this case it seems Onfleet is expecting a rather specific format for the team field. Assuming you only have a limited number of teams you can simply use a Switch node before your Onfleet node and then use the repsective values from the dropdown?

On the Switch node, simply check the value of the team field of your incoming items, then route the item to the Onfleet node which then uses the correct drodown value rather than relying on the expression here.

After checking this Onfleet API documentation page, perhaps you could also try an expression like {{ [ $json["Team_ID"] ] }}? It seems they expect an array of team IDs, so this seems worth a shot.

Like so:

Example workflow:

this spits out " Issues:

  • The value “[Array: [“Redacted_team_ID”]]” is not supported!"

I’m going to read up on the switch documentation and report back if we run into issues or successes. appreciate the help on this so far

Would this just be n8n warning you because it can’t find validate the input value returned by the expression or does it actually prevent the node from being executed?

As a last resort you could also consider using the HTTP Request in order to send the API request from Create worker directly to the Onfleet API without n8n applying any logic on its own.

I think it actually prevents the node from being executed. And I don’t have the knowledge to send the API request directly myself.