create github organisation using API - github-api

I am trying to create organisation using github enterprise API, i am following this -
https://docs.github.com/en/enterprise-server#2.22/rest/reference/enterprise-admin#create-an-organization
Below is the API tried :
curl -u acme-admin:token -X POST -H "Accept: application/vnd.github.v3+json" https://acme.example.com/api/v3/admin/organizations -d '{"login":"acme-admin","admin":"acme-admin","profile_name":"exampleorg"}'
Response is as shown below, do any one have any clue about this ? the user "acme-admin" exists in the github enterprise and this user is administrator only.
{
"message": "Validation Failed",
"errors": [
{
"resource": "Organization",
"code": "custom",
"field": "login",
"message": "login is not available"
},
{
"resource": "Organization",
"code": "missing_field",
"field": "admins"
}
],
"documentation_url": "https://docs.github.com/enterprise/2.22/user/rest/reference/enterprise-admin#create-an-organization"
}

A similar script mentions:
curl -i -H "Authorization: token $gitub_api_token" ...
You can see that header defined in "REST API / Other authentication methods".
Check if this works better than -u acme-admin:token.

Related

Unable to create neather policies or things on Eclipse Ditto local version

i was able to run successfully local Eclipse Ditto version using docker container latest version downloaded from https://github.com/eclipse/ditto/tree/master/deployment/docker.
Following the tutorial I was training first to create a new policy using the following curl:
curl -X PUT 'http://localhost:8080/api/2/policies/my.test:policy' -u 'ditto:ditto' -H 'Content-Type: application/json' -d '{
"entries": {
"owner": {
"subjects": {
"nginx:ditto": {
"type": "nginx basic auth user"
}
},
"resources": {
"thing:/": {
"grant": [
"READ","WRITE"
],
"revoke": []
},
"policy:/": {
"grant": [
"READ","WRITE"
],
"revoke": []
},
"message:/": {
"grant": [
"READ","WRITE"
],
"revoke": []
}
}
}
}
}'
401 - Authentication is possible but has failed or not yet been provided, the same one I'm getting from the local swagger.
Trying to create it on sandbox: https://www.eclipse.org/ditto/http-api-doc.html#/
I'm getting: Undocumented
TypeError: NetworkError when attempting to fetch resource.
What I'm missing? i choose the API version 2 and authorize myself as a ditto user to start working.
Is there any additional configuration required to start working with the local version?
And what I'm doing wrong with the sandbox?

Microsoft Graph API: SharePoint: Get items list in "default Drive" of "root Site"

Overview
I am familiar in using Microsoft Graph API with File scoping for handling items within root directory if (items specifically folders and files) in Microsoft OneDrive; create/delete/metadata for Folders and upload/delete/metadata for Files.
Using Microsoft Graph API again, I wish to do perform the same actions in handling Folders and Files, create/delete/metadata for folders and upload/delete/metadata for files, in Microsoft SharePoint within the default Drive of root Site as mention prior for OneDrive.
Problem
I having the following issues with Microsoft Graph API in using for handling items within default Drive or root Site:
Using default Drive ID in handling items within a site's drive.
Create/Delete/Get-Metadata of a folder item within default Site's Drive.
Upload/Delete/Get-Metadata of a file item within a parent folder.
The following Microsoft Graph API call returns root site's default drive's metadata**:
curl "https://graph.microsoft.com/v1.0/sites/root/drive" \
--request GET \
--verbose \
--write-out 'HTTPSTATUS:%{http_code}' \
--silent \
--header "authorization: Bearer [** ACCESS_TOKEN **]" \
--header "Content-Type: application/json"
JSON Response example is:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
"createdDateTime": "2012-06-12T17:27:56Z",
"description": "Share a document with the team by adding it to this document library.",
"id": "b!mWxqgLJ9mESqZI4PrP0Gs-F4hgLaCRlCkVuON4nbwzhkKbcyWdM1Tb5WEzNJ0C60",
"lastModifiedDateTime": "2015-03-03T02:39:56Z",
"name": "Shared Documents",
"webUrl": "https://docusign2com.sharepoint.com/Shared%20Documents",
"driveType": "documentLibrary",
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"lastModifiedBy": {
"user": {
"displayName": "System Account"
}
},
"quota": {
"deleted": 0,
"remaining": 0,
"total": 0,
"used": 0
}
}
Problem Getting Drive Metadata
Taking the unencoded drive_id for the current default Drive in root Site, [** DRIVE_ID **]:
"id": "b!mWxqgLJ9mESqZI4PrP0Gs-F4hgLaCRlCkVuON4nbwzhkKbcyWdM1Tb5WEzNJ0C60"
Encode drive_id, [** URL-Encoded DRIVE_ID **]:
"id": "b%21mWxqgLJ9mESqZI4PrP0Gs-F4hgLaCRlCkVuON4nbwzhkKbcyWdM1Tb5WEzNJ0C60"
Using the encoded drive_id, we can get the metadata for that drive another way:
curl "https://graph.microsoft.com/v1.0/sites/root/drives/[** URL-Encoded DRIVE_ID **]" \
--request GET \
--verbose \
--header "authorization: Bearer [** ACCESS_TOKEN **]" \
--header "Content-Type: application/json"
Response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
"createdDateTime": "2012-06-12T17:27:56Z",
"description": "Share a document with the team by adding it to this document library.",
"id": "[** DRIVE_ID **]",
"lastModifiedDateTime": "2015-03-03T02:39:56Z",
"name": "Shared Documents",
"webUrl": "https://docusign2com.sharepoint.com/Shared%20Documents",
"driveType": "documentLibrary",
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"lastModifiedBy": {
"user": {
"displayName": "System Account"
}
},
"quota": {
"deleted": 0,
"remaining": 0,
"total": 0,
"used": 0
}
}
Next, I tried listing the items within the root Site's default Drive by appending /items:
curl "https://graph.microsoft.com/v1.0/sites/root/drives/[** URL-Encoded DRIVE_ID **]/items" \
--request GET \
--verbose \
--header "authorization: Bearer [** ACCESS_TOKEN **" \
--header "Content-Type: application/json"
And it fails:
{
"error": {
"code": "invalidRequest",
"message": "The request is malformed or incorrect.",
"innerError": {
"request-id": "0a212014-b386-45d9-9c36-bae2dd6cea8f",
"date": "2020-02-07T06:51:15"
}
}
}
API Path Requested
What is the expected path for getting the list of all items within a default drive's root within root site?
Thank you
Instead of using .../v1.0/sites/$site_id/drives/... for working with drives, I switched to using .../v1.0/drives/$drive_id/..., and this worked.
The following Microsoft Graph API request above using /v1.0/sites/root/drives/[** URL-Encoded DRIVE_ID **], the return previously acquired default drive (identified by [** DRIVE_ID **]) metadata:
curl "https://graph.microsoft.com/v1.0/drives/[** url-encoded DRIVE_ID **]" \
--request GET \
--verbose \
--silent \
--header "authorization: Bearer [** ACCESS_TOKEN **]" \
--header "Content-Type: application/json"
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
"createdDateTime": "2012-06-12T17:27:56Z",
"description": "Share a document with the team by adding it to this document library.",
"id": "[** DRIVE_ID **]",
"lastModifiedDateTime": "2015-03-03T02:39:56Z",
"name": "Shared Documents",
"webUrl": "https://docusign2com.sharepoint.com/Shared%20Documents",
"driveType": "documentLibrary",
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"lastModifiedBy": {
"user": {
"displayName": "System Account"
}
},
"quota": {
"deleted": 0,
"remaining": 0,
"total": 0,
"used": 0
}
}
This returns the root folder of default drive:
curl "https://graph.microsoft.com/v1.0/drives/[** url-encoded DRIVE_ID **]/root" \
--request GET \
--verbose \
--silent \
--header "authorization: Bearer [** ACCESS_TOKEN **]" \
--header "Content-Type: application/json"
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('[** url-encoded DRIVE_ID **]')/root/$entity",
"createdDateTime": "2012-06-12T17:27:56Z",
"id": "[** ROOT_FOLDER_ID **]",
"lastModifiedDateTime": "2020-02-07T16:04:09Z",
"name": "root",
"webUrl": "https://docusign2com.sharepoint.com/Shared%20Documents",
"size": 27781340,
"parentReference": {
"driveId": "b!mWxqgLJ9mESqZI4PrP0Gs-F4hgLaCRlCkVuON4nbwzhkKbcyWdM1Tb5WEzNJ0C60",
"driveType": "documentLibrary"
},
"fileSystemInfo": {
"createdDateTime": "2012-06-12T17:27:56Z",
"lastModifiedDateTime": "2020-02-07T16:04:09Z"
},
"folder": {
"childCount": 5
},
"root": {}
}
Now with root folder of default drive, the list of children folders can be requested:
curl "https://graph.microsoft.com/v1.0/drives/[** url-encoded DRIVE_ID **]/items/[** ROOT_FOLDER_ID **]/children" \
--request GET \
--verbose \
--silent \
--header "authorization: Bearer [** ACCESS_TOKEN **]" \
--header "Content-Type: application/json"

Unable to retrieve secure score results for my tenant

I'm trying out the Secure Score API
curl -XGET "https://graph.microsoft.com/v1.0/reports/getTenantSecureScores(period=1)/content" -H "Authorization: Bearer ..." -H "Content-Type: Application/json"
but I'm getting the following error
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'reports'.",
"innerError": {
"request-id": "ba775602-1e27-43e3-858f-4203801b072d",
"date": "2017-06-20T10:49:08"
}
}
The token I am using has the required set of permissions as mentioned here
"roles":["User.ReadWrite.All","Group.ReadWrite.All","Files.ReadWrite.All","Reports.Read.All"]
Am I missing anything?
Let's change from v1.0 to beta and your issue is fixed.

Not getting intended data from instagram subscription api call

I followed the subscription api(https://www.instagram.com/developer/subscriptions/) and created a subscription request like this:
curl -F 'client_id=clientId' \
-F 'client_secret=clientSecret' \
-F 'object=user' \
-F 'aspect=media' \
-F 'verify_token=my-verify-token' \
-F 'callback_url=https://xx.xx.com/igwh' \
https://api.instagram.com/v1/subscriptions/
and got response as bellow:
{
"meta": {
"code": 200
},
"data": {
"object": "user",
"object_id": null,
"aspect": "media",
"subscription_id": 0,
"callback_url": "https://xx.xx.com/igwh",
"type": "subscription",
"id": 0
}
}
My app is in live mode, so is that normal to get the "object_id": null, "subscription_id": 0 and "id": 0 onto the response?
After that when my another authenticated instagram account shared a media then I got notification to my callback url but seems to me lack of information:
[
{
"changed_aspect": "media",
"object": "user",
"object_id": "111111",
"time": 1484290271,
"subscription_id": 0,
"data": {
"media_id": "1111-11"
}
}
]
I said lack of information because a media have "id", "images", "caption", "link" etc which I was expecting as a response.
Because otherwise I have to call normal api(Media enpoints) call again to get those things. Is there anything I missed to get the subscription or have different way to get?
https://www.instagram.com/developer/subscriptions/
this endpoint says "When we have new data, we'll POST this data to your callback URL. We'll explain more about what this URL needs to do later on this page."
Although I can't get the subscription api response if I comment on the media(which I had got the notification in my callback url) or liked on the media/comment.
Is that those things not supported by instagram? Does anyone have this issue or any help will be appreciated?
May be this answer of mine will be helpful to people having same problem.

api call to upload an image to object storage container on bluemix node js app

Iam trying to upload an image to object storage container and get the url of that image deployed on bluemix using a node js app.To achieve this i need to use a post or put api call.I could able to authenticate with the object storage but not able to achieve the functionality through the api calls.So,I need some help on the api calls.So can some one help me out in this if you had worked on such kind of api calls with images on object storage.(using object-storage npm).Even share any kind of sample working api calls.Any help appreciated.
Object storage api's are derived from the OpenStack Swift API spec. In order to add an object of any sort to a Bluemix Object Storage container, you'll need to do 2 things:
Authenticate to the Object Storage instance to obtain an authorization token.
Perform actions on the container using the token obtained.
I assume that you already have access to the JSON credentials provided by the object storage service ... similar to:
{
"auth_url": "https://identity.open.softlayer.com",
"domainId": "nice_long_hex_value",
"domainName": "some_number",
"password": "not_gonna_tell_you",
"project": "object_storage_hex_value",
"projectId": "project_hex_value",
"region": "dallas",
"userId": "another_fine_hex_value",
"username": "some_text_with_hex_values"
}
Step 1: Obtain X-Auth-token. 4 items (user_id, user_name, password and auth_url) should come from your provided credentials.
curl -i -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"id": "another_fine_hex_value",
"password": "not_gonna_tell_you"
}
}
},
"scope": {
"project": {
"id": "project_hex_value"
}
}
}
}' "{auth_url}/v3/auth/tokens" | tee response.txt | grep X-Subject-Token | sed 's/.*X-Subject-Token: \([^ ]*\).*/\1/g' | tee >(awk '{printf("\nX-Auth-Token: %s\n\nJSON Response Body:\n", $0)}' > /dev/tty) | sed -n '/{/,$p' <response.txt | python -m json.tool && rm response.txt
This should result in a 500+ Line JSON Response BODY (take note of the public interface for the region of dallas within the swift endpoints array) similar to …
{
"token": {
"methods": [
"password"
],
"roles": [
{
"id": "redacted",
"name": "ObjectStorageOperator"
}
],
"expires_at": "2016-03-09T20:26:39.192753Z",
"project": {
"domain": {
"id": "some_hex_value",
"name": "some_int"
},
"id": "another_hex_value",
"name": "one_more_hex_value"
},
"catalog": [
...
{
"endpoints": [
{
"region_id": "london",
...
},
{
...
},
{
"region_id": "dallas",
"url": "https://dal.objectstorage.open.softlayer.com/v1/AUTH_",
"region": "dallas",
"interface": "public",
"id": "some_unique_id"
},
{
...
},
{
...
},
{
...
}
],
"type": "object-store",
"id": "hex_values_rock",
"name": "swift"
},
...
],
"extras": {},
"user": {
"domain": {
"id": "hex_value",
"name": "another_fine_int"
},
"id": "tired_of_hex_values_yet?",
"name": "cheers_one_more_hex_value_for_the_road"
},
...
}
}
Specifically, we want to identify the Swift Object Storage API url in the form:
https://dal.objectstorage.open.softlayer.com/v1/AUTH_some-hex-value
https://dal.objectstorage.open.softlayer.com/v1/AUTH_some-hex-value is
linked to your desired object storage region (dallas, london, …) and associated with a public interface. This will be found within the endpoints section which includes the name “swift”.
Even more importantly, within the generated HTTP Response Header of this /v3/auth/tokens call is an authentication token that we also need to record to facilitate subsequent authenticated HTTP API calls.
Here is a sample of the HTTP Response Headers
Connection: Keep-Alive
Content-Length: 12089
Content-Type: application/json
Date: Wed, 09 Mar 2016 19:26:39 GMT
Keep-Alive: timeout=5, max=21
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5
Vary: X-Auth-Token
X-Subject-Token: gAAAAABW4Hjv5O8yQRwYbkV81s7KC0mTxlh_tXTFtzDEf3ejsP_CByfvvupOeVWWcWrB6pfVbUyG5THZ6qM1-BiQcBUo1WJOHWDzMMrEB5nru69XBd-J5f5GISOGFjIxPPnNmEDZT_pahnBwaBQiJ8vrg9p5obdtRJeuxk7ADVRQFcBcRhAL-PI
x-openstack-request-id: req-26a078fe-d0a7-4a75-b32d-89d3461c55f1
The X-Subject-Token is the important response header. Its value will be reused within all subsequent HTTP Request Headers using the header X-Auth-Token. Obvious, right?
Step 2: With this token, let's add an object to a container named "ibmjstart".
curl -s -X PUT -i -H "Content-Type: text/plain"\
-H "X-Auth-Token: X-Subject-Token from above"\
-H "Cache-Control: no-cache"\
-d "Awesome sauce is best served warm" "{API AUTH URL obtained above}/ibmjstart/test.txt"
If all goes well, this should result in a new container named ibmjstart which contains a text file named test.txt with a single line of content.

Resources