หากสนใจแชร์ความคิดเห็นเกี่ยวกับ Google Ads API
ลงชื่อสมัครเพื่อรับคำเชิญให้เข้าร่วมการศึกษาวิจัยผู้ใช้
ส่วนหัวของคําขอที่ไม่บังคับ
เมื่อใช้ช่องที่ไม่บังคับในเมธอดคำขอ คุณต้องสร้างข้อความคำขอนอกเมธอดและส่งเป็นพารามิเตอร์เดียว
ส่วนหัวของคำขอที่ไม่บังคับ เช่น ส่วนหัว validate_only
ในเมธอด GoogleAdsService.Search
ไม่ได้อยู่ในลายเซ็นเมธอดในฐานะพารามิเตอร์คีย์เวิร์ด จึงต้องตั้งค่าในข้อความคำขอโดยตรง
หากต้องการตรวจสอบว่าฟิลด์ออบเจ็กต์คำขอต้องระบุหรือไม่ คุณสามารถอ้างอิงคำจำกัดความ protobuf สำหรับบริการ และมองหาฟิลด์ที่มีคำอธิบายประกอบ [(google.api.field_behavior) =
REQUIRED]
ต่อไปนี้เป็นตัวอย่างการตั้งค่าฟิลด์ validate_only
ที่ไม่บังคับในคำขอ GoogleAdsService.Search
request = client.get_type("SearchGoogleAdsRequest")
request.customer_id = customer_id
request.query = query
request.validate_only = True
response = googleads_service.search(request=request)
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-03-04 UTC
[null,null,["อัปเดตล่าสุด 2025-03-04 UTC"],[[["When using optional fields in Google Ads API requests, construct the request message separately and pass it as a single parameter to the method."],["Optional request headers like `validate_only` are set directly on the request message, not as keyword parameters in the method signature."],["You can identify required or optional request fields by checking the protobuf definitions and looking for the `[(google.api.field_behavior) = REQUIRED]` annotation."],["To use optional fields, create an instance of the request message type, populate its fields including the optional ones, and then pass it to the API method."]]],[]]