Bitbucket api returns 400 for commit pull requests - bitbucket-api

I'm trying to get the list of pull requests for a given git commit in Bitbucket. I can successfully curl both the commit, and the list of pull requests:
curl -u $USER:$APP_TOKEN https://api.bitbucket.org/2.0/repositories/meekrosoft/demo_bitbucket_pipe/commit/d7f5d5b11b268a70684f8683b411caed57da9d34/
curl -u $USER:$APP_TOKEN https://api.bitbucket.org/2.0/repositories/meekrosoft/demo_bitbucket_pipe/pullrequests
However when I try to get the pull requests for a commit that has an associated pull request I get a 400 error:
curl -u $USER:$APP_TOKEN https://api.bitbucket.org/2.0/repositories/meekrosoft-ztl/test_pipe/commit/d7f5d5b11b268a70684f8683b411caed57da9d34/pullrequests
{"error": "Invalid or unknown installation"}%

Per the Bitbucket docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commit/%7Bcommit%7D/pullrequests
Pull Request Commit Links app must be installed first before using
this API; installation automatically occurs when ‘Go to pull request’
is clicked from the web interface for a commit’s details.
I tried to do it in Chrome but it didn't work (console said something about CSP). I was able to do it in Safari and get this endpoint to work. You'll have to do this once per workspace.

It seems to be some kind of new feature that you can only select once you view a pull in the user interface 🤦

Related

Making an HTTP request with a blank user agent

I'm troubleshooting an issue that I think may be related to request filtering. Specifically, it seems every connection to a site made with a blank user agent string is being shown a 403 error. I can generate other 403 errors on the server doing things like trying to browse a directory with no default document while directory browsing is turned off. I can also generate a 403 error by using a tool like Modify Headers for Google Chrome (Google Chrome extension) to set my user agent string to the Baidu spider string which I know has been blocked.
What I can't seem to do is generate a request with a BLANK user agent string to try that. The extensions I've looked at require something in that field. Is there a tool or method I can use to make a GET or POST request to a website with a blank user agent string?
I recommend trying a CLI tool like cURL or a UI tool like Postman. You can carefully craft each header, parameter and value that you place in your HTTP request and trace fully the end to end request-response result.
This example straight from the cURL docs on User Agents shows you how you can play around with setting the user agent via cli.
curl --user-agent "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" [URL]
In postman its just as easy, just tinker with the headers and params as needed. You can also click the "code" link on the right hand side and view as HTTP when you want to see the resulting request.
You can also use a heap of hther HTTP tools such as Paw and Insomnia, all of which are quite well suited to your task at hand.
One last tip - in your chrome debugging tools, you can right click the specific request from the network tab and copy it as cURL. You can then paste your cURL command and modify as needed. In Postman you can import a request and past from raw text and Postman will interpret the cURL command for you which is particularly handy.

wget won't download files I can access through browser

I am an amateur historian trying to access newspaper archives. The server where the scans are located "works" using an outdated tif viewer that doesn't seem to actually work at all anymore. I can access the files individually in chrome without logging in, but when I try to use wget or curl, I'm told that viewing the file is unauthorized, even when I use my login info, and even when using my cookies from chrome.
Here is an example of one of the files: https://ulib.aub.edu.lb/nahar/images2/7810W2/78101001.TIF
When I put this into chrome, it automatically downloads the file even though I cannot access the directory itself, but when I use wget, I get the following response: "401 unauthorized Username/Password Authentication Failed."
This is the basic wget command I'm using (if I can get it to work at all, then I'll input a list of the other files):
wget --no-check-certificate https://ulib.aub.edu.lb/nahar/images2/7810W2/78101001.TIF
I've tried variations with and without cookies, with a blank user, with and without login credentials, As I'm sure you can tell, I'm new to this sort of thing but eager to learn.
From what I can see, authentication on your website is done with HTTP basic. This kind of authentication is not using HTTP cookies, it is using HTTP Authorization header. You can pass HTTP basic credentials to wget with the following arguments.
wget --http-user=YourUsername --http-password=YourPassword https://ulib.aub.edu.lb/nahar/images2/7810W2/78101001.TIF

Acess Issue on Jira/Atlassian with R

I got a Atlassian/Jira account where projects are listed on. I would like to import the various issues in order to make some extra analysis. I found a way to connect to Atlassian/Jira and to import what I want on Python:
from jira import JIRA
import os
impot sys
options = {'server': 'https://xxxxxxxx.atlassian.net'}
jira = JIRA(options, basic_auth=('admin_email', 'admin_password'))
issues_in_proj = jira.search_issues('project=project_ID')
It works very well but I would like to make the same thing in R. Is it possible ? I found the RJIRA package but there are three problems for me:
It's still on a dev version
I am unable to install it as the DESCRIPTION file is "malformed".
It's based on a jira server URL: "https://JIRAServer:port/rest/api/" and I have a xxxxx.atlassian.net URL
I also found out that there are curl queries :
curl -u username:password -X GET -H 'Content-Type: application/json'
"http://jiraServer/rest/api/2/search?jql=created%20>%3D%202015-11-18"
but again it is based on a "https://JIRAServer:port/rest/api/" form and in addition I am using windows.
Do someone have an idea ?
Thank you !
The "https://JIRAServer:port/rest/api/" form is the Jira REST API https://docs.atlassian.com/jira/REST/latest/
As a rest api, it just makes http method calls and gives you data.
All jira instances should expose the rest api, just point your browser to your jira domain like this:
https://xxxxx.atlassian.net/rest/api/2/field
and you will see all the fields you have access to, for example
This means you can use php, java or a simple curl call from linux to get your jira data. I have not used RJIRA but if you dont want to use it, you can still use R (which I have not used) and make an HTTP call to the rest api.
These two links on my blog might give you more insight:
http://javamemento.blogspot.no/2016/06/rest-api-calls-with-resttemplate.html
http://javamemento.blogspot.no/2016/05/jira-confluence-3.html
Good luck :)

CURL command not working with simple HTTP GET but browser does

I tried to fetch the data from https://m.jetstar.com/Ink.API/api/flightAvailability?LocaleKey=en_AU&ChildPaxCount=0&DepartureDate=2016-03-21T00%3A00%3A00&ModeSaleCode=&Destination=NGO&CurrencyCode=TWD&AdultPaxCount=1&ReturnDate=&InfantPaxCount=0&Origin=TPE
it couldn't be done by curl -vv https://m.jetstar.com/Ink.API/api/flightAvailability?LocaleKey=en_AU&ChildPaxCount=0&DepartureDate=2016-03-21T00%3A00%3A00&ModeSaleCode=&Destination=NGO&CurrencyCode=TWD&AdultPaxCount=1&ReturnDate=&InfantPaxCount=0&Origin=TPE it will return nothing,
However, browser can fetch whole data.
What's wrong with that?
It seems to me that "m.jetstar.com" is filtering requests that don't include the headers that a browser would send. Your curl statement needs to fully emulate a browser to get the data. One way to see what I'm saying is to open developer tools in Google Chrome, select the network tab, run the URL in the browser then goto to the row indicating the call and right click, then copy the request as a curl statement, then paste it to a notepad and you'll see all the additional headers you need. Additionally, that curl statement should work.
check if you have set any HTTP_REQUEST variable for proxy settings. Verify by calling curl command in verbose mode. curl -v
I had setup a variable earlier and when I check the curl output in verbose mode it told me that it was going to proxy address. Once I deleted the HTTP_REQUEST variable from advanced system settings, it started working. Hope it helps.

Not ablle to receive token from OAuth authentication in Apigee tool

I have created AccessTokenClientCredential and RefreshAccessToken in OAuth proxy through Apigee tool.
When I tried to access "https://damuorgn-prod.apigee.net/oauth/client_credential/accesstoken?grant_type=client_credentials&client_id=07VoDotbGhyl3aG8GxjkyXivoTNH9oiQ&client_secret=fb8ZOrAUUSGp3FAv" URL after mentioning client Id and client secret ID, page is empty. It does not displays any error or displays with Token value.
Steps followed to create token from below URL
"http://apigee.com/docs/gateway-services/content/secure-calls-your-api-through-oauth-20-client-credentials".
Please advise.
Regards,
Damodaran
I tried both Test and Prod environment but there was no luck.
I have requested for Curl software installation. Is there any other way to test this URL without Curl software. Your immediate reply is appreciated. Thanks!
Curl https://damuorgn-test.apigee.net/oauth/client_credential/accesstoken?grant_type=client_credentials -X POST -d 'client_id=qnYUqb6j3uGraRAh7JF9d651nUXNwMCC&client_secret=mjHIFMcTDCa3YQ6f'
Could you please check on this link from Curl software ?
It looks like there may be a couple of issues:
When I try your URL, I get a "CLASSIFICATION_FAILURE" error - which means the proxy can't be found. I noticed that you're using "damuorgn-prod.apigee.net" when you might have deployed your proxy to the test environment, and meant to use: "damuorgn-test.apigee.net".
In step 5.2 of the document you referenced, it says to use POST instead of GET. So you might try this:
curl https://damuorgn-test.apigee.net/oauth/client_credential/accesstoken?grant_type=client_credentials -X POST -d 'client_id=07VoDotbGhyl3aG8GxjkyXivoTNH9oiQ&client_secret=fb8ZOrAUUSGp3FAv'
(When I try this, I get an "invalid client id" error, but maybe that client_id is no longer valid?)
Hope that helps,
Scott

Resources