Problem with behaviors sort_by parameter


I trying to get behavior data in sorting manner.

But I am facing INVALID_PARAMETER error while using sort_by parameter with “partner_source, audience_size” values in GET targeting_criteria/behaviors call. i was wondering are “partner_source, audience_size” are correct values or its there is mistake in GET targeting_criteria/behaviors doc.

Below is my response for call
“message”: “Expected a field in (created_at, updated_at, deleted, name) with the format “<field_name>-<asc/desc>”, got “partner_source” for sort_by”,
“parameter”: “sort_by”

Thanks in advance for any help.

GET targeting_criteria/behaviors not working
GET targeting_criteria/behaviors not working

Hey @roshan_cygnet - if you have a look at the [Sorting] ( part of our docs, you will see that you need to append either -asc or -desc to the end of each sortable parameter. So in this case, you would need to use partner_source-asc or partner_source-desc.

You make a good point though, the examples aren’t clear enough and assume that you have already read the Sorting section of the docs. We will address that :+1:


hi @andrs,

I forget to mention before that i have tried with appending -asc or -desc in before call but it give relative same error.
for example call this : response with below error

“errors”: [
“message”: “Expected a field in (created_at, updated_at, deleted, name) with the format “<field_name>-<asc/desc>”, got “audience_size-desc” for sort_by”,
“parameter”: “sort_by”


Oh I see - yup, you are right @roshan_cygnet - I jumped the gun there because usually most people miss out on adding -asc or -desc.

The valid sort_by values for that endpoint are created_at , updated_at, deleted and name - we’ll make a note to update our docs accordingly. Here’s an example for sorting by name in ascending order:

twurl -H "/0/targeting_criteria/behaviors?sort_by=name-asc" | jq .


hi @andrs thanks for help and confirmation :smile: :thumbsup:


Getting behaviors using the sort_by parameter is not working for me, not even after the update to the v1 of the Ads API:


GET /1/targeting_criteria/behaviors?sort_by=name-asc HTTP/1.1
Connection: close
Accept-Encoding: gzip, deflate
User-Agent: Zend\Http\Client
Authorization: [edited out]


HTTP/1.1 500 Internal Server Error
connection: close
content-disposition: attachment; filename=json.json
content-encoding: gzip
content-length: 109
content-type: application/json;charset=utf-8
date: Thu, 19 May 2016 13:26:47 GMT
server: tsa_b
set-cookie: guest_id=v1%3A146366440778904727;; Path=/; Expires=Sat, 19-May-2018 13:26:47 UTC
strict-transport-security: max-age=631138519
x-access-level: read-write
x-api-version: 1.0
x-connection-hash: 6c1bb7de26aa5fc795cb4339d670abb7
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-response-time: 21
x-runtime: 0.010107
x-transaction: 4e0ec253c30eef04
x-xss-protection: 1; mode=block

{"errors":[{"code":"INTERNAL_ERROR","message":"Internal Error"}],"request":{"params":{}}}

This has never worked for me. @andrs: could you please help me with this?

Do I need any kind of whitelisting for this to work?

Thank you.