Not able to download log files using following API - api

We are not able to download log files. Once run below command, it is getting unable to parse object filter.
curl -X GET -u : -g https://api.service.softlayer.com/rest/v3/SoftLayer_Event_Log/getAllObjects.json

I'm able to retrieve the Event Logs through SoftLayer's private network, I used the same request:
curl -X GET -u $user:$apiKey -g https://api.service.softlayer.com/rest/v3/SoftLayer_Event_Log/getAllObjects.json
According to the exception, it seems that you are sending something else in the request.
Are you able to make others api calls? can you try again please? Did you have success before with this request?
Also, can you try with the public endpoint: https://api.softlayer.com instead of https://api.service.softlayer.com

Related

Login Github with Curl

I tried call this command
curl -l -u "my_user_name" https://my-enterprise-github.com
Then, I input my password manually.
But it returns this
<html><body>You are being redirected.</body></html>
Please explain what's wrong with my command.
Thank you.
cURL should not be used for access to GitHub's (or most web) UI without specific reasons. GitHub provides an API to allow accessing data as a well-defined structure.
You mentioned wanting to get-a-single-pull-request. This relies on a URL pattern following GET /repos/:owner/:repo/pulls/:number.
So if you had a GitHub account, facebook, and wanted to look up a specific pull request 15947 in react-native. The full URL would be
https://api.github.com/repos/facebook/react-native/pulls/15947
The cURL command would be
curl -u osowskit -X GET https://api.github.com/repos/facebook/react-native/pulls/15947
Note that:
You will likely want to start using a PAT or OAuth token instead of username/password
There are tools that make exploring the GitHub API easier. postman or octokit
To start with you may want the -L flag. From the cURL Frequently Asked Questions
3.8 How do I tell curl to follow HTTP redirects?
Curl does not follow so-called redirects by default. The Location: header that informs the client about this is only interpreted if you're using the -L/--location option. As in:
curl -L http://redirector.com
Not all redirects are HTTP ones, see 4.14
There's also a CLI now that can be helpful for many similar use-cases:
https://cli.github.com/
$ gh pr list
Showing 2 of 2 open pull requests in Roblox/service-comms-nomad
#16 chi1 Traefik 1.7 GLB jobs chi1-glb-prep
#6 Cgt/t2 cgt/t2

How to run a rundeck job like a rest call from application?

I created a simple job of mkdir in rundeck.Now I wanted to run that job some node application.So how can I get the api for the job so that I can call that rest call from my application and run the job.
I just tried a post call for this from my postman but didnt worked.
http://rundeckhost:4440/api/1/job/uuid/run
Gave the following error:
(unauthenticated) is not authorized for: /api/1/job/ec0852b7-222a-4372-ad4b-808892777019/executions
Can someone point me to any references or any info on how can we run the job through a rest call from our application.Basically how to get the rest url for the job to run?
You have one of two ways to authenticate: http://rundeck.org/docs/api/#authentication
For your purpose it will probably be easier to use the authtoken type. See here for your choices for authtoken types: http://rundeck.org/docs/administration/access-control-policy.html#api-token-authorization
Roughly, you will do something like this:
curl -H "X-Rundeck-Auth-Token: $API_TOKEN" \
--data-urlencode "${NODEFILTER:-}" \
--data-urlencode "argString=${JOB_OPTIONS:-}" \
-X POST "${RD_URL}/api/12/job/$JOB_UUID/run"

gitlab API unathorized

I tried to create a project by importing manually my git repo. I followed that tutorial :
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/import.md
At the end I got that error :
* Failed trying to create xxx (xxx/xxx.git)
Errors: {:base=>["Failed to create repository via gitlab-shell"]}
By reading gitlab-shell.log file I discover that access to the API is forbidden I got the following error :
{"message":"401 Unauthorized"}
With that URL :
https://xxx/api/v4/internal/check
Do you know how can I fix this ?
You have to make a HTTP Post request in order to achieve this.
Clearly, according to https://docs.gitlab.com/ee/api/README.html you do not have the authorization. This is because you are not using the Gitlab Private token.
You can go to Profile -> settings -> generate a Private token. Once generated, copy it to your clipboard and use it in your post request.
Best way to use it is by Curl:
Ex:
curl --request POST --header "PRIVATE-TOKEN: XXXX -k "https://example.com//api/v4/projects/11/jobs/16863/retry"
u need to genrate private Token :
open your account gitlab -> settings->genrate private Token

import.io curl simple data integration

I want to get the simple api integration from https://import.io via curl. I created a magic api and struggle now to get the data.
Do I use the magic api on the browser, it works fine. But with curl I get a {"code":"NOT_AUTHORIZED"}. Obvious that the authentication did not work.
Here's my code
#!/bin/bash
login=foo#bar.com
pass=foobar
userid=foo-bar
apikey=1f2o3o4b5a6r
curl --user $login:$pass https://api.import.io/store/data/033fbe66-13b7-4cf2-ba9c-58183a567a6f/_query?input/webpage/url=https%3A%2F%2Fwww.zalando.de%2Flp-ons-wom-sale-cat-v1%2F%3Forder%3Dsale&_user=$userid&_apikey=$apikey
What am I doing wrong? And how do I get it run with curl?
I could get it running. Found https://github.com/import-io/bashtractor/blob/master/bashtractor.sh which solved my problem.

Confluence REST API Authorization Failure

I am trying to use the Confluence REST API to create a page. I am using the curl example off of the documentation found HERE. Every time I try to run a terminal command using this curl I get a response that says 'HTTP Status 401 - Basic Authentication Failure - Reason : AUTHENTICATION_DENIED'. I see that someone else had a similar issue regarding their C# code, but there was never a resolution given. Hopefully someone with experience will be able to tell me what I am doing wrong. My curl is listed below with the sensitive parts replaced in <> format.
curl -u <USER>:<PASSWORD> -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"new page","space":{"key":"<PAGEKEY>"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' https://<SERVER>/wiki/confluence/rest/api/content/ | python -mjson.tool
I was finally able to resolve this. Through a combination of the answer here How to create new page in Confluence using their REST API? and using a login that had the appropriate permissions.