Multiple API Filter is not working

Omraj Krishnamurthy April 9, 2023

Hi, 

I'm trying to get the Pull Requests between or after some specific date(s) and from a specific destination branch. 

Eg: "https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pullrequests/?q=created_on>"2023-04-09T00:00:00.000Z"&destination.branch.name="master"

For the above Query, I get the Pull Requests greater than "2023-04-09" but it includes all destination branches. 

If I place "destination.branch.name" at the first place and then "created_on" parameter, then I get the Pull Requests from master branch but it doesn't filter by greater than specified created_on date.

Eg: "https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pullrequests/?q=destination.branch.name="master"&created_on>"2023-04-09T00:00:00.000Z"

It looks like only the first filter is accounted and then the remaining is ignored. 

Any suggestion to resolve this issue is much appreciated.

 

1 answer

1 accepted

0 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 11, 2023

Hello @Omraj Krishnamurthy

Thank you for reaching out to Atlassian Community!

If you would like to query for multiple parameters in your API call, you will need to use logical operators (AND, OR) between the different conditions, like in the following example:

curl -X GET -u username:app_password https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/pullrequests/?q=updated_on+%3E+2023-01-09T08%3A21%3A50%2B00%3A00+AND+destination.branch.name="test_branch"

which would translate to the following condition : 

updated_on > 2023-01-09T08:21:50+00:00 AND destination.branch.name="test_branch"

The date and time values are encoded. Depending on the tool you are using to make the request, it might automatically encode it for you, but in case you would like to encode it manually you could use a third-party tool like https://www.urlencoder.org/.

You are also welcome to check for additional examples of querying for multiple conditions on the Bitbucket API - Filter and sort objects documentation.

Hope that helps! Let me know in case you have any questions.

Thank you, @Omraj Krishnamurthy !

Patrik S

Omraj Krishnamurthy April 12, 2023

Thank you very much. Its working now.

Like Patrik S likes this
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 13, 2023

Happy to have been of some help! Feel free to reach out to Atlassian Community in case you need help in the future :) 

Thank you, @Omraj Krishnamurthy !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events