רוצים לשתף משוב על 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)
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 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."]]],[]]