Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route Optimization API doesn't work #5783

Closed
dodomui opened this issue Nov 2, 2024 · 1 comment
Closed

Route Optimization API doesn't work #5783

dodomui opened this issue Nov 2, 2024 · 1 comment

Comments

@dodomui
Copy link

dodomui commented Nov 2, 2024

When trying with the example according to Google provided. I received error below.
Anyone could advise?

Error Message
{"code":3,"details":"INVALID_REQUEST: Validation caught 1 error(s). Here is the first one: In shipments[0].pickups[0]: arrival_indexanddeparture_index should always both be present if (and only if) the request uses index-based locations (2)","metadata":{"endpoint-load-metrics-bin":[{"type":"Buffer","data":[49,93,227,154,112,244,2,211,63,73,184,207,164,158,24,177,178,63]}],"grpc-server-stats-bin":[{"type":"Buffer","data":[0,0,77,213,43,71,0,0,0,0]}],"pc-high-bwd-bin":[{"type":"Buffer","data":[75,103,73,89,69,81]}]},"note":"Exception occurred in retry method that was not classified as transient"}

Code

const response = await routeoptimizationClient.optimizeTours({
            "parent": "projects/1081295492861",
            "populate_polylines": true,
            "populate_transition_polylines": true,
            "model": {
              "shipments": [
            {
              "deliveries": [
                {
                  "arrival_location": {
                    "latitude": 37.789456,
                    "longitude": -122.390192
                  },
                  "duration": {seconds: 250}
                }
              ],
              "pickups": [
                {
                  "arrival_location": {
                    "latitude": 37.794465,
                    "longitude": -122.394839
                  },
                  "duration": {seconds: 150}
                }
              ]
            },
            {
              "deliveries": [
                {
                  "arrival_location": {
                    "latitude": 37.789116,
                    "longitude": -122.395080
                  },
                  "duration": {seconds: 250}
                }
              ],
              "pickups": [
                {
                  "arrival_location": {
                    "latitude": 37.794465,
                    "longitude": -122.394839
                  },
                  "duration": {seconds: 150}
                }
              ]
            },
            {
              "deliveries": [
                {
                  "arrival_location": {
                    "latitude": 37.795242,
                    "longitude": -122.399347
                  },
                  "duration": {seconds: 250}
                }
              ],
              "pickups": [
                {
                  "arrival_location": {
                    "latitude": 37.794465,
                    "longitude": -122.394839
                  },
                  "duration": {seconds: 150}
                }
              ]
            }
          ],
          "vehicles": [
            {
              "end_location": {
                "latitude": 37.794465,
                "longitude": -122.394839
              },
              "start_location": {
                "latitude": 37.794465,
                "longitude": -122.394839
              },
              "cost_per_kilometer": 10.0,
              "cost_per_hour": 40.0
            }
          ]
            //   "globalStartTime": "2024-12-13T00:00:00.000Z",
            //   "globalEndTime": "2024-12-14T06:00:00.000Z"
            }
        });
@sofisl
Copy link
Contributor

sofisl commented Nov 5, 2024

Hi @dodomui, as this library does a best effort to respond to API-specific questions, this question would be better placed in the "Discussions" part of this repo, where other community members can help advise as well. However, I will mention the quickstart does run this sample successfully, so I'd encourage you to start by running that sample and seeing the differences between the two.

@sofisl sofisl closed this as completed Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants