Id attributes are missing in OneNote page content fetched via Microsoft Graph - microsoft-graph-api

We are creating a OneNote page using the below Graph endpoint. Several id attributes are present in the HTML content of this page.
POST .. groups/{group-id}/onenote/sections/{section-id}/pages
To get the OneNote page content again, we are using the below graph end point.
GET ..groups/{group-id}/onenote/pages/{page-id}/content?includeIds=true
In the case of one of our customers, when we get the page content, we don't see those id attributes that we added when creating the page. Other customers do not experience this problem.
We checked that we did not PATCH anything on that page before it started returning page content without id attributes.
In debugging, we noticed that if we create a OneNote page and get the page content immediately, we get the IDs back, but if we do it later, we don't.
Here are the details of the latest get request for that page content.
curl $'https://graph.microsoft.com/v1.0/groups/e07ccbcc-3464-4777-aa3a-466cc0db328c/onenote/pages/1-1ea50c06f867479a84ffa6a1f3710e0d\u002157-7b03c43d-87ff-4692-8664-d3a42822b7ed/content?includeIds=true' \
-H 'Connection: keep-alive' \
-H 'Cache-Control: no-cache' \
-H 'sec-ch-ua: "Chromium";v="92", " Not A;Brand";v="99", "Microsoft Edge";v="92"' \
-H 'Pragma: no-cache' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'Authorization: Bearer
-H 'client-request-id: 95a44839-0407-4fe7-b497-294c9375ea1f' \
-H 'Accept: application/json, text/plain, */*' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 Edg/92.0.902.84' \
-H 'If-Modified-Since: Mon: 26 Jul 1997 05:00:00 GMT' \
-H 'Origin: https://app.boarddecisions.com' \
-H 'Sec-Fetch-Site: cross-site' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Referer: https://app.boarddecisions.com/' \
-H 'Accept-Language: en-GB,en;q=0.9,en-US;q=0.8' \
--compressed
Additional Details about ids -
In OneNote page content, for different table elements, we have id attributes.
Example -
<table border="1" data-type="tasks" id="meetingDecisionsTable" style="width:1080px">
......
</table>
We usually get these IDs back in the data-id attribute like below.
For one specific customer, we are not getting any data-id attribute in the page content. We are unable to reproduce this issue outside of the customer's environment. Therefore, it should be tracked with the request id provided above.

Related

Mendeley - can not search catalog anymore "client is not allowed"

Since last week, the catalog search on Mendeley API is giving me the following result:
{
"message": "Client ID <client_id> is not allowed",
"status": 403
}
I am using standard code in Python that worked before:
mendel = Mendeley(client_id=client_id, client_secret=client_secret)
auth = mendel.start_client_credentials_flow()
session = auth.authenticate()
print(session.catalog.search('Nitrogen dynamics', view='all').list(50).items)
And I have the same result using curl:
curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-u client_id:client_secret \
-d "grant_type=client_credentials&scope=all" \
https://api.mendeley.com/oauth/token
curl -X GET "https://api.mendeley.com/search/catalog?access_token={access_token}"

Unable to get refresh_token from vimeo ouath

As per a standard ouath2.0 Authorization grant code glow. The code received in query can be used to get an access_token as well a refresh_token.
But I am not able to get refresh_token from vimeo. Just the access_token is being provided with the below curl
curl 'https://api.vimeo.com/oauth/access_token' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Referer: http://localhost:4200/vimeoCallback?code=0772xxxxsomeCode0003f7d818e207b' \
-H 'Authorization: Basic YTMtxxxbasicbase64(KEY:ID)XXXXUg==' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36' \
-H 'Content-Type: application/json' \
--data-binary '{"grant_type":"authorization_code","code":"0772xxxxsomeCode0003f7d818e207b","redirect_uri":"http://localhost:4200/vimeoCallback"}' \
Please suggest me what I need to get the refresh_token
Your message parameters look good - you just need to send them as form encoded data rather than as JSON - see this link for the syntax.

Bash CLI with HTTParty and rails to handle multiple headers one of which includes a slash

The following connects to the API's server
httparty -a post -H Content-Type:application/json "https://test.co.uk/interface/search"
and returns an error message (which is by design).
However, if another header is added:
httparty -a post -H Content-Type:application/json -H Accept-Encoding:gzip,deflate "https://test.co.uk/interface/search"
an error occurs in the ruby JSON parser
.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/json-2.1.0/lib/json/common.rb:156:in
`parse': 765: unexpected token at '' (JSON::ParserError)
No amount of escaping with quotes changes the situation.
httparty -a post -H 'Content-Type:application/json' -H Accept-Encoding:gzip,deflate "https://test.co.uk/interface/search"
same error...
On the other hand, if one excludes the 'application/json' header, multiple headers can be submitted, obtaining a server response (same error message from API server).
httparty -a post -H Accept-Encoding:gzip,deflate -H Content-Length:578 -H Host:test.co.uk -H Connection:Keep-Alive "https://test.co.uk/interface/search"
How can multiple headers be submitted, with the 'application/json' string pass ruby's JSON parsing filter?
Personally I use HTTPie, try to curl like this way.
curl -H "Accept-Encoding:gzip,deflate" \
-H "Content-Length:578" \
-H "Host:test.co.uk" \
-H "Connection:Keep-Alive" \
-X POST \
"https://test.co.uk/interface/search"

How do I delete a docker image from docker hub via command line?

I create docker image for testing in my Jenkins pipeline, uploading this to Docker hub and deploy those to Kubernetes. At the end of the testing process, I want to delete the test image from Docker hub (not from test machine). How do I delete docker hub image from command line?
Use the Docker Hub API as documented in:
https://docs.docker.com/v1.7/reference/api/docker-io_api/#delete-a-user-repository
I've just tested a delete of a test image with curl:
curl -X DELETE -u "$user:$pass" https://index.docker.io/v1/repositories/$namespace/$reponame/
Replace $user and $pass with your user and password on the Docker Hub, respectively; and replace $namespace (in my case it's the same as the $user) and $reponame with the image name (in my case was test).
You can delete any <TAG> from your Docker Hub <REPO> by using curl and REST API to the Docker Hub website (at https://hub.docker.com/v2/) rather that to the Docker Hub registry (at docker.io). So if you are not afraid of using an undocumented API, this currently works:
curl -i -X DELETE \
-H "Accept: application/json" \
-H "Authorization: JWT $HUB_TOKEN" \
https://hub.docker.com/v2/repositories/<HUB_USERNAME>/<REPO>/tags/<TAG>/
The HUB_TOKEN is a JSON Web Token passed using Authorization HTTP header, and it can be obtained by posting your credendials in JSON format to the /v2/users/login/ Docker Hub endpoint:
HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"$HUB_USERNAME\", \"password\": \"$HUB_PASSWORD\"}" https://hub.docker.com/v2/users/login/ | jq -r .token)
2FA => Personal Access Token
Note than when you have 2FA enabled, you’ll need a personal access token (the only password accepted by the API when using 2FA).
Dockerhub has a REST backEnd, then you can use it... it is just skipping the FE...
For example:
export USERNAME=myuser
export PASSWORD=mypass
export ORGANIZATION=myorg (if it's personal, then it's your username)
export REPOSITORY=myrepo
export TAG=latest
curl -u $USERNAME:$PASSWORD -X "DELETE" https://cloud.docker.com/v2/repositories/$ORGANIZATION/$REPOSITORY/tags/$TAG/
This will delete one tag...
In my case, I have microservices, then the REPOSITORY = the Microservice Name...
If I want to delete all the older images, I can iterate on this....
For any PowerShell friends.
$params = #{username='mickey';password='minnie'}
$response = Invoke-RestMethod -Uri https://hub.docker.com/v2/users/login/ -Method POST -Body $params
$token = $response.token;
$orgName = "mickey" #organization or user name
$repoName = "disney"
$Uri = $("https://hub.docker.com/v2/repositories/$orgName/$repoName/")
Invoke-WebRequest -Method Delete -Uri $Uri -Headers #{Authorization="JWT " + $token; Accept= 'application/json' }
It is possible. For a shortcut, Open dev tools in Chrome, go to the network tab. Delete a tag manually from Docker Hub. You will see a request on the network tab in dev tools that goes to https://cloud.docker.com/v2/repositories//tags/. Just right click on that request, Copy, Copy as Curl. It should look something like this...
curl "https://cloud.docker.com/v2/repositories//tags//" -X DELETE -H 'Pragma: no-cache' -H 'Origin: https://cloud.docker.com' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36' -H 'Accept: application/json' -H 'Cache-Control: no-cache' -H 'Referer: https://cloud.docker.com/user/repository/registry-1.docker.io/reponame/tags' -H 'Cookie: ' --compressed
You can now use the new BETA (as of 2022-01) Docker Hub API
https://docs.docker.com/docker-hub/api/latest/
and the docker-hub CLI tool among a few other options.
hub-tool login
hub-tool tag rm myrepo/myimage:mytag

How to implement stress test with NodeJS LoadTest

I need to stress test a link that works with curl command below:
curl "http://192.168.1.191:7007/api/v1/users/login" -H "Accept-Encoding: gzip, deflate" -H "Accept-Language: en-US,en;q=0.8,vi;q=0.6" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -H "Connection: keep-alive" --data "username=test&password=test" --compressed
How can I implement stress test with LoadTest
I found the solution.
I created a file test.txt with content:
username=test&password=test&
After that, run test command:
loadtest "http://192.168.1.191:7007/api/v1/users/login" -n 1000 -c 5 -p test.txt -T 'application/x-www-form-urlencoded'
Please make note that you have to add '&' in the end of test.txt file. This is a issue of LoadTest. I have had a pull request to fix it at https://github.com/alexfernandez/loadtest/pull/63

Resources