Rest APi searchstream response

346 views
Skip to first unread message

teambs

unread,
Sep 17, 2022, 1:30:29 AM9/17/22
to Google Ads API and AdWords API Forum
Hi

For SearchStream Rest Api response, we are expecting json arrays properly formatted, as the doc says search stream gives out multiple json arrays,

But we are getting stream response as string where we have to concat it and parse it, for smaller reults this is ok, But for large records it is hitting range error.

Are we missing any thing in stream response format?

How to handle this?

Regards

Google Ads API Forum Advisor

unread,
Sep 19, 2022, 1:43:40 AM9/19/22
to saranyap...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching us out. I am Sherwin from Google Ads API support team. I hope that you are doing well today.

Moving forward to your concern, for logging, you may check this documentation on how to enable it. If this wont work for you, could you please provide us the complete request and response logs with request ID and request header generated on your end? You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Kind regards,
Google Logo
Sherwin Vincent
Google Ads API Team
 


ref:_00D1U1174p._5004Q2ePgPj:ref

teambs

unread,
Sep 27, 2022, 7:05:08 AM9/27/22
to Google Ads API and AdWords API Forum
hi Thanks for the response, we will send the details, but can you please confirm what is the rest api search stream format ?

Google Ads API Forum Advisor

unread,
Sep 27, 2022, 9:33:15 AM9/27/22
to saranyap...@gmail.com, adwor...@googlegroups.com

Hi,

Thanks for getting back to us.

For REST API search stream format, you may refer below cURL sample:

curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \

--header "Content-Type: application/json" \

--header "developer-token: ${DEVELOPER_TOKEN}" \

--header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \

--header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \

--data '{

"query": "

  SELECT campaign.name,

    campaign_budget.amount_micros,

    campaign.status,

    campaign.optimization_score,

    campaign.advertising_channel_type,

    metrics.clicks,

    metrics.impressions,

    metrics.ctr,

    metrics.average_cpc,

    metrics.cost_micros,

    campaign.bidding_strategy_type

  FROM campaign

  WHERE segments.date DURING LAST_7_DAYS

    AND campaign.status != 'REMOVED'

"

}'

Response body:

If successful, the response body contains data with the following structure:

Response message for GoogleAdsService.SearchStream.

JSON representation


[
  {
    "results": [
      {
        object (GoogleAdsRow)
      }
    ],
    "fieldMask": string,
    "summaryRow": {
      object (GoogleAdsRow)
    },
    "requestId": string
  }
]

For more information, you may refer to this guide.

Regards,

Google Logo
Yasar
Google Ads API Team
 


ref:_00D1U1174p._5004Q2ePgPj:ref

teambs

unread,
Sep 28, 2022, 1:21:18 AM9/28/22
to Google Ads API and AdWords API Forum
Thank you for the reply, as mentioned if sucessfull, response body is containing the above said json, but we are not seeing json response while streaming that is if we request 100,000 records then an array of results object containing each 10,000 records are being sent, which are not at all formatted correctly, we are trying to get the json records processing using streams, as these are in the format of string until we recieve the entire json it is becoming useless,
we want to process the records as soon as the streaming had started, for this purpose the chunks that are being sent as part of stream should be in json format, please let us know if json for stream chunks are possible from your side or we need to wait for the entire stream to be completed and then process the json

Regards

Google Ads API Forum Advisor

unread,
Sep 28, 2022, 3:53:28 AM9/28/22
to saranyap...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for providing more details to your concern.

To take a closer look at the issue and to provide an accurate suggestion, would you be able to provide complete request and response logs with request ID and request header generated on your end where we can see the sample chunk of results that are not in JSON format? I asked because I haven't encountered what you've mentioned yet when I am doing reports using the REST API, the results are always in JSON format.

Regards,
Google Logo
Ernie John
Google Ads API Team
 


ref:_00D1U1174p._5004Q2ePgPj:ref
Reply all
Reply to author
Forward
0 new messages