จัดการข้อผิดพลาดคําขอ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
นักพัฒนาแอปในเขตเศรษฐกิจยุโรป (EEA)
Routes API จะแสดงข้อความแสดงข้อผิดพลาดเป็นส่วนหนึ่งของการตอบกลับการเรียกเมธอด ตัวอย่างเช่น หากคุณละเว้นคีย์ API จากคำขอ เมธอดจะแสดงผลดังนี้
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"status": "PERMISSION_DENIED"
}
}
หากคุณละเว้นพารามิเตอร์ของเนื้อหาที่ต้องระบุ เช่น origin
วิธีการจะแสดงผลดังนี้
{
"error": {
"code": 400,
"message": "Origin and destination must be set.",
"status": "INVALID_ARGUMENT"
}
}
ดูข้อมูลเพิ่มเติมเกี่ยวกับข้อผิดพลาดและการจัดการข้อผิดพลาดได้ที่หัวข้อข้อผิดพลาด
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-06-20 UTC
[null,null,["อัปเดตล่าสุด 2025-06-20 UTC"],[[["\u003cp\u003eThe Routes API provides error messages within its responses to indicate issues with the request.\u003c/p\u003e\n"],["\u003cp\u003eErrors are returned as JSON objects containing an \u003ccode\u003eerror\u003c/code\u003e field with details about the issue, such as a code, message, and status.\u003c/p\u003e\n"],["\u003cp\u003eMissing API keys result in a \u003ccode\u003ePERMISSION_DENIED\u003c/code\u003e error with a 403 code.\u003c/p\u003e\n"],["\u003cp\u003eOmitting required parameters like \u003ccode\u003eorigin\u003c/code\u003e leads to an \u003ccode\u003eINVALID_ARGUMENT\u003c/code\u003e error with a 400 code.\u003c/p\u003e\n"],["\u003cp\u003eFurther details on errors and their handling can be found in the Google Cloud API Design Guide on Errors.\u003c/p\u003e\n"]]],[],null,["# Handle request errors\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nThe Routes API returns error messages as part of the\nresponse to a method call. For example, if you omit the API key from the\nrequest, the method returns: \n\n```json\n{\n \"error\": {\n \"code\": 403,\n \"message\": \"The request is missing a valid API key.\",\n \"status\": \"PERMISSION_DENIED\"\n }\n}\n```\n\nIf you omit a required body parameter, such as `origin`, the method\nreturns: \n\n```json\n{\n \"error\": {\n \"code\": 400,\n \"message\": \"Origin and destination must be set.\",\n \"status\": \"INVALID_ARGUMENT\"\n }\n}\n```\n\nFor more information on errors and error handling, see\n[Errors](https://cloud.google.com/apis/design/errors)."]]