Step 1: Set Up Your n8n Project

  1. Log in to your n8n account.
  2. Click New Workflow to create a blank workflow.
  3. Give the workflow a descriptive name.

Step 2: Define Input Variables

  1. Add an Edit Fields node:
    • This node creates input variables for the API call.
  2. Define input fields as text variables:
    • originZIP
    • destinationZIP
    • weight
  3. Ensure inputs are stored in text format, as required by the API.

Step 3: Import API Request via cURL

  1. Visit the SpreadsheetWeb API Documentation.
  2. Navigate to the calculatesinglesimple endpoint:
    • Use the Try it out feature to test with sample inputs.
  3. Copy the cURL request provided after execution.
    Example cURL:
     
    curl -X 'POST' \ 'https://api.spreadsheetweb.com/calculations/calculatesinglesimple' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "request": { "workspaceId": "your-workspace-id", "applicationId": "your-application-id", "inputs": { "originZIP": "{{ $json.originZIP }}", "destinationZIP": "{{ $json.destinationZIP }}", "weight": "{{ $json.weight }}" }, "outputs": ["cost"] } }'
  4. Add an HTTP Request node to n8n:
    • Click Import cURL and paste the cURL command.

Step 4: Configure the HTTP Request Node

  1. Verify Parameters: Ensure the following details are accurate:
    • API Endpoint:
      https://api.spreadsheetweb.com/calculations/calculatesinglesimple
    • Headers:
      • Content-Type: application/json
    • Body: Map the request body to dynamic input fields:
       

      {
      "request": {
      "workspaceId": "your-workspace-id",
      "applicationId": "your-application-id",
      "inputs": {
      "originZIP": "{{ $json.originZIP }}",
      "destinationZIP": "{{ $json.destinationZIP }}",
      "weight": "{{ $json.weight }}"
      },
      "outputs": ["cost"]
      }
      }

    Replace workspaceId and applicationId with your SpreadsheetWeb credentials.

  2. Map variables to the request body:
    • Drag and drop originZIP, destinationZIP, and weight from the Edit Fields node to the JSON body.

Step 5: Handle API Response

  1. Add a second Edit Fields node to handle the API response.
  2. Extract and store the API output:
    • Define a new field: calculatedCost.
    • Map it to the key in the API response:
      $json.response.outputs.cost

       

Step 6: Test the Workflow

  1. Run the workflow with sample inputs:
    • originZIP: “10001”
    • destinationZIP: “90001”
    • weight: “1”
  2. Verify the output:
    • The calculatedCost field should display the API result (e.g., “8.5785”).