i want to create a file on my github account using github api through postman.
github api to create a file on github account:
PUT /repos/:owner/:repo/contents/:path
can anyone tel me how to use this api in postman.
i have my public github account : https://github.com/ritzygithub/myfirstRepo
and in postman header i set
Authorization type to OAuth 2
Authorization : token <token>
PUT request with url: https://api.github.com/repos/ritzygithub/myfirstRepo/
Can you please help me out in this
i just figured it out.. posting my answer here so that if anyone is facing same issue then this can help them.
In postman, set as PUT request with below URL
https://api.github.com/repos/YourUsername/YourRepo/contents/file.txt
Add Body:
{
"message": "my commit message",
"committer": {
"name": "My name",
"email": "my email"
},
"content": "base64encoded"
}
Header:
Content-Type : application/json
Authorization : token
Refer below Screenshot:
Hope this helps.
Thanks
Related
update: even such a request get bad credential ==>
curl -H "Authorization: token [token]" https://api.github.com
===============
I made a request for GitHub OAuth like this in my iOS app:
URL: https://github.com/login/oauth/authorize,
params: client_id: ****, redirect_uri: app_url, scope: "repo", state: "0"
After redirection from Safari I get a code. I need to access to two things:
User data, like email and etc. Also updating user data.
List of repositories and commits in public and private repos.
I make following requests:
URL: https://api.github.com/user, get and patch
Header: Authorization: token [code]
URL: https://api.github.com/repos/:username/:repoName
Header: Authorization: token [code]
But unfortunately, I get the following error:
401, Unauthorized
{
"message": "Bad credentials",
"documentation_url": "https://developer.github.com/v3"
}
What is the problem and how can I solve it?
As it is said in this blob (NOT the main documentation) you have to exchange token (which is temporary) with a bearer token via this api:
the main api
Here comes the documentation for others:
Github blob documentation
The following curl command works:
curl -u your_git_name:your_personal_access_token https://api.github.com/user
I'm looking for help of somebody who knows something about Jira add-ons.
I'm trying to implement Jira add-on with an ability to create issues on behalf of a user.
So, I completed all steps (as I think) leading me to my goal, but I faced a problem with impersonating. When I try to create an issue using Jira REST API, I receive the following error:
{
"error": "Add-on 'com.example.myapp' disallowed to impersonate the user because 'no valid active user exists'"
}
What was done:
Folowing the getting started tutorial I created the add-on descriptor:
{
"name": "Hello World",
"description": "Atlassian Connect app",
"key": "com.example.myapp",
"baseUrl": "https://url.ngrok.io",
"vendor": {
"name": "Example, Inc.",
"url": "http://example.com"
},
"authentication": {
"type": "jwt"
},
"scopes": [
"act_as_user",
"read",
"write",
],
"lifecycle": {
"installed": "/api/created",
},
"apiVersion": 1
}
I also implemented webhook to handle 'installed' callback from add-on like described here. So, when a user installs the add-on the webhook will receive the following object:
{
'key': 'com.example.myapp',
'clientKey': '<client key>',
'oauthClientId': '<OAuth client ID>',
'publicKey': '<public key>',
'sharedSecret': '<shared secret>',
'serverVersion': '100095',
'pluginsVersion': '1.250.0',
'baseUrl': 'https://<user's domain>.atlassian.net',
'productType': 'jira',
'description': 'Description',
'eventType': 'installed'
}
Using this data I generated JWT signed with the shared secret like described in the tutorial. So, my JWT payload includes the following claims:
{
'iss': 'urn:atlassian:connect:clientid:<OAuth client ID>',
'sub': 'urn:atlassian:connect:useraccountid:<client key>',
'tnt': 'https://<user's domain>.atlassian.net',
'iss': '<created at>',
'exp': '<created at + 1 minute>'
}
The next step I performed is access token generation using auth.atlassian.io/oauth2/token endpoint and the following parameters:
grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&assertion=<my JWT>&scope=ACT_AS_USER READ WRITE
The result of all these actions is an access token witch I can use to perform REST API requests. But the error described above returned every time I try to create Jira issue performing POST [user's domain].atlassian.net/rest/api/2/issue/ with Authorization: Bearer [access_token] header.
What I've noticed is that account ID in installed callback object (clientKey) has 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' (uuid) format. But when I open my account in Jira (account in witch the add-on is installed) I see that the account ID in URL has 'YYYYYY:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' format. I prepended the subject in my JWT payload with YYYYYY part:
'sub': 'urn:atlassian:connect:useraccountid:'YYYYYY:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
and generated a new access token using this JWT. I've used new access token to create an issue and it was successfully created, the reporter of the issue is a user installed my add-on, just like I wished.
Finally, the question is: where can I find that YYYYYY part for my add-on? How to get it automatically? What I've missed following the tutorials? Any help will be appreciated.
Thank you!
background:
I am trying to build an application that will copy a public repository to the logged in account.
Now i am trying to do a source import in PostMan and i am using the following settings:
i make a PUT request to this link:
https://api.github.com/repos/{myusername}/{empty github repository}/import
with the following header:
Accept:application/vnd.github.barred-rock-preview
With this body:
{
"vcs": "git",
"vcs_url": "https://github.com/{owner of repo i want to copy}/{repo i want to copy}",
"vcs_username": "{myusername}",
"vcs_password": "{mypassword}"
}
I have read the github API for importing repositories. But i am getting the following response from the server:
{
"message": "Not Found",
"documentation_url":
"https://developer.github.com/v3/migrations/source_imports/#start-an-import"
}
Why does the server return a Not Found? How do i get this to work
It need Authentication else will get 404 Not Found
using username and password for authentication
Put URL:
https://{myusername}:{mypassword}#api.github.com/repos/{myusername}/{myreponame}/import
Request Body
{
"vcs": "git",
"vcs_url": "https://github.com/{ownerRepo}/{ownerRepoName}"
}
vcs_username and vcs_password used for remote repo not yours.
I have successfully installed Documentum REST API in my environment. When I go to http://localhost:8080/dctm-rest/repositories I am able to see the repositories successfully. But when I when I try to open any cabinet URL there, it prompts for username password.
I put a password there and it works fine.
But when I send the request using Postman it shows this error
"status": 401,
"code": "E_GENERAL_AUTHENTICATION_ERROR",
"message": "Authentication failed.",
"details": "Full authentication is required to access this resource"
and when sending with Authorization in the format
Authorization : Basic (base64 value of "username:password")
it shows
"status": 400,
"code": "E_INPUT_ILLEGAL_ARGUMENTS_PARAM",
"message": "Illegal argument {0} provided with value {1}.",
"details": "Parameter conditions \"dql\" not met for actual request
parameters: "
You Have to turn on the Interceptor to make proxy-authenticated request so that it has the same request context as of browser.
I tried few links and used Basic Auth, which worked!
I Need API to stop the running application, after some search I've found this API
http://apidocs.cloudfoundry.org/263/apps/updating_an_app.html
if I want to test it with postman how can I obtain token and where should I put it inside postman ?
Edit
i've tried like following with postman
Put
https://[api]/v2/apps/211c82e2-7316-45b6-9ae6-1df4dzz74772/stop
Header
Authorization : bearer <token>
"Content-Type":"application/x-www-form-urlencoded"
I got error:
{
"description": "Unknown request",
"error_code": "CF-NotFound",
"code": 10000
}
Any idea?
To get the token you can run cf oauth-token from the CLI.
You can use that token in Postman by adding an 'Authorization' HTTP header.
E.g.
Authorization: bearer token_you_got_by_running_cf_oauth-token