Query not working
I'm trying to fetch pull requests by created date but the query is not working.
i tried multiple queries with dates but none seems to be working.
Can anyone help me with how to structure the queries with dates
https://api.bitbucket.org/2.0/repositories/${workspace}/${repository}/pullrequests?q=state="MERGED"&created_on>2023-11-19T14:19:29
welcome to the community.
Unfortunately I couldn´t find any query in the bitbucket API docu that supports a queryParameter called "created_on".
Could you maybe send information where this is documented?
Best
Stefan
Thanks @Stefan Salzl for the speedy reply.
Here it's listed that we can use created_on to filter some of the following endpoint.
What I'm trying to achieve is to fetch all merged PRs between two release branches.
If this isn't possible, Is there any other way to achieve it?
https://developer.atlassian.com/cloud/bitbucket/rest/intro/#filtering
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ah... thanks for the hint. wasn´t aware of that. I´ll have to experiment with them.
Meanwhile:
Could you tell/show us how you are calling the API/in which way (automation/curl call/...) and what you get as a result/error?
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm using axios to call the API and I'm not getting any errors but only the state filter ( state = "MERGED") is working
const INITIAL_URL = `https://api.bitbucket.org/2.0/repositories/${workspace}/${repository}/pullrequests?q=state="MERGED"&created_on>2023-11-17T05:11:02`
const fetchAllPRs = async (URL) => {
try {
const res = await axios.get(URL, {
headers: {
Authorization: `Bearer ${token}`,
}
})
return res.data
} catch(e) {
console.log(e)
return null
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This:
https://api.bitbucket.org/2.0/repositories/{workspace}/[repository}/pullrequests?q=state="merged"&created_on<2023-02-27
as well as this:
https://api.bitbucket.org/2.0/repositories/{workspace}/[repository}/pullrequests?q=state="merged" AND created_on<2023-02-27
worked in my instance (I did the calls via postman, maybe you need to first encode your query before sending).
the encoded call looks like:
https://api.bitbucket.org/2.0/repositories/{workspace}/[repository}/pullrequests?q=state=%22merged%22%20and%20created_on%3C2023-02-27
Furthermore one more question:
do you get an empty reply or an error?
because I could see that you are filtering for any created_on date greater (>) than today (which makes it logic that it doesn´t provide any results). Could you try to change the "greater than" to a "smaller than (<) ?
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
AWESOME!!!! 💪💪
so good to hear you got that working ✌✌
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.