Update Patch Microsoft Graph API Planner Task Detail using JSON cURL produces error 409 conflict - rest

I receive a 409 error when trying to update a planner task, with the following error detail ... "The attempted changes conflicted with already accepted changes. Read the latest state and resolve differences."
It seems to happen every time I try to update the planner task. I can literally create a new task, then try to update it and it immediately throws the 409 error. No one has changed anything on the Microsoft side. If I wait a few minutes, the same error occurs.
What's interesting is that if i run the update literally twice, back to back ... the second time it does accept the change without error.
The URL is: "https://graph.microsoft.com/v1.0/planner/tasks/" & $microsoftplannerTaskID
CURL OPTIONS are:
"-X PATCH " &
" -H "Authorization: Bearer " & $$userToken & """ &
" -H "Content-Type: application/json"" &
" -H "If-Match: W/\"" & $microsoftPlannerTasketag &"\""" &
" -d #$PlannerTaskDetails" &
" -D $responseHeaders" //returns error codes
the $PLANNERTASKDETAILS are:
"{ " &
""bucketId": "" & #MicrosoftBucketID & "", " &
""title": "" & #title & "", " &
""dueDateTime": "" & $dueDateTimeFormatted & "" " &
"}"

found that the issue was after an update, I need to get a new etag value before updating the same planner task again. so you need to update, then get, then update again.

Related

Getting the list of all branches in a GitHub organisation without triggering Rate Limit, using Bash?

While trying to establish a list of incoming GitHub commits I've stumbled accross the GitHub rate api limits, of 60 calls per hour. As explained in this answer, one can get the lists of branches with an API call using:
https://api.github.com/repos/{username}/{repo-name}/branches
However, that triggers the rate limit for the average GitHub organisation/user. So I thought I'd try a different approach, using RSS/atom format. However, as that same answer explains, the atom format/rss feed seems to depend on the user having a list of all branches in a repository. This question asks for an overview of all commits in a repository, yet instead it is given an answer for all commits in the default branch of the repository. And this question receives a working answer that triggers the rate limit, as it relies on at least 1 API call per repository.
Hence, I would like to ask: How could one get a list of all branches of a GitHub user, using at most 1 GitHub API call?
Note, using atom views would be perfectly fine, however, I have not found an atom view like: https://github.com/:owner/:repo/commits.atom or https://github.com/:owner/:repo/branches.atom that displays all branches in a repository. I would strongly prefer a solution that does not rely on a third party like: https://rsshub.app/github/repos/yanglr as I imagine, they too will at some point start rate-limiting.
My current approach is to scrape the source code of https://github.com/:user/:repo/branches using bash. However, I imagine there might exist a more efficient solution to this.
MWE
Thanks to the comments, I was ble to find a bash MWE to perform a GraphQL query using terminal. It is given in this answer, where bearer is not a variable, it is the means of identification and the ...... should be your personal GitHub Access token. I am currently looking into how to get the repositories beyond the 1st hundred. Then I'll look at how to get the branches of those repositories.
Attempt I
The following query yields a json with the repositories and first 4 branches in each repository of a user!
name:examplequery.gql.
query {
repositoryOwner(login: "somegithubuser") {
repositories(first: 40) {
edges {
node {
nameWithOwner
refs(
refPrefix: "refs/heads/"
orderBy: { direction: DESC, field: TAG_COMMIT_DATE }
first: 4
) {
edges {
node {
... on Ref {
name
}
}
}
}
}
}
}
}
}
Next, a bash script is made that runs the query:
#!/usr/bin/env bash
# Runs graphql query on GitHub. Execute with:
# ./run_graphql_query.sh examplequery1.gql
GITHUB_PERSONAL_ACCESS_TOKEN_GLOBAL="your_github_personal_access_token"
if [ $# -ne 1 ]; then
echo "usage of this script is incorrect."
exit 1
fi
if [ ! -f $1 ];then
echo "usage of this script is incorrect."
exit 1
fi
# Form query JSON
QUERY=$(jq -n \
--arg q "$(cat $1 | tr -d '\n')" \
'{ query: $q }')
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: bearer $GITHUB_PERSONAL_ACCESS_TOKEN_GLOBAL" \
--data "$QUERY" \
https://api.github.com/graphql
It can be ran with:
./run_graphql_query.sh examplequery1.gql
There are two more issues to resolve before I can answer the question. How I can iterate over all repositories instead of only the first 100. How I can parse the json into a list of branches per repository.

Jenkins http plugin to upload file using rest

I am trying to upload a file to a rest server from jenkins using http plugin. I have a jenkins pipelie where a step involves loading a file(type formData)
to a server using rest.
the server side method uses two parameters:
(#FormDataParam("file") InputStream file, #FormDataParam("fileName") String fileName)
I am using the below method
def filename = "${WORKSPACE}/Test.txt"
data="""{ \"fileName\" : \"Test.txt\" }"""
resp3 = httpRequest consoleLogResponseBody: true,url: "http://<url>",contentType:'APPLICATION_OCTETSTREAM',customHeaders:[[name:'Authorization', value:"Basic ${auth}"]],httpMode: 'POST',multipartName: 'Test.txt',uploadFile: "${filename}",requestBody:data,validResponseCodes: '200'
but when I run the status code is 400 and in the server logs the message is that no filestream and no filename is received i.e not able to get both the arguments.
Please let me know where it is getting wrong
Regards
You can try using curl instead of built-in Jenkins methods:
curl -XPOST http://<url> -H 'Content-Type: application/octet-stream' -H 'Authorization: Basic ${auth}' --data-binary '{\"fileName\" : \"Test.txt\" }'
You can debug it first from within shell. Once it's working, wrap it in sh directive:
sh "curl ..."
Since I was running on windows so bat + curl worked for me .With this workaround I was able to transfer files using jenkins and rest
However using httpRequest from jenkins inbuild library is still not working.

About the wrong URI in tcf-agent_git.bb in Poky

I'm a new hand and try to build a xilinx by pocto.
As the guide, I cloned repositories (branch thud), source oe-... and change MACHINE="zedborad-zynq7", then bitbake petalinux-image-minimal, but I get following error:
ERROR: tcf-agent-1.7.0+gitAUTOINC+dad3a6f568-r0 do_fetch: Fetcher
failure: Fetch command ...
https://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git
refs/:refs/ failed with exit code 128, output: fatal: repository
'https://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git/' not
found ... ERROR: Task
(~/poky/meta/recipes-devtools/tcf-agent/tcf-agent_git.bb:do_fetch)
failed with exit code '1'
The issue is that the statement in tcf-agent_git.bb:
SRC_URI = "git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent \
It is NOT the wrong address, In fact, I can clone successfully with this address. On the other hand, any my modify on this variable will NOT work either.
I already grep -rn "eclipse.org", but only find this file.
Any recommendation will be welcome.
Thanks lot.
——————————————————————————
I can't resolve this issue finally.
I find that the builder does NOT fetch from the address the SRC_URL offer at all, instead, it fetches from a mirror given somewhere.
As a test, I edited the .bb file, add PREMIRRORS="" and MIRROS="", and add protocal=git statement for the SRC_URI. The statements are effective realy, the builder fetches from the SRC_URL address, but the protocol is still HTTPS, the function still fails.
My solution is cloning the source manually, and putting it to corresponding directory, in order to let the builder know this, I also touch a package_name.done and chmod 777 in the same directory, then I can continue.
I've run into the exact same issue using Xilinx Yocto stack (rel-v2018.3 branch). For me, the problem wasn't in the tcf-agent_git.bb recipe in core/meta/recipes-devtools/tcf-agent, but in the tcf-agent_%.bbappend file in meta-petalinux/recipes-devtools/tcf-agent. In there, I replaced
SRC_URI = " \
git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git;branch=master;protocol=https \
file://fix_ranlib.patch;striplevel=2 \
file://ldflags.patch \
file://tcf-agent.init \
file://tcf-agent.service \
"
with
SRC_URI = " \
git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git;branch=master \
file://fix_ranlib.patch;striplevel=2 \
file://ldflags.patch \
file://tcf-agent.init \
file://tcf-agent.service \
"
and it finishes building correctly.
The former used to work fine last time I built the image (a few months ago) but for some reason the protocol=https option makes it fail now.
Your SRC_URI seems wrong.
it should be
SRC_URI = "git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git \
This one is working perfect for me.
Note : The back slash () at the end means you have multiple line SRC_URI. correct it if you have only single line.
In December 2021, using branch rel-v2020.1, I needed to change the line into :
SRC_URI = "git://git.eclipse.org/r/tcf/org.eclipse.tcf.agent.git;protocol=https \

Nagios Custom Plug-in(https authentication) not working as expected

I am writing a plugin to check authentication to a https site and then search for a text in the response html,body to confirm successful login. I have created the following plugin
#!/bin/bash
add_uri='--no-check-certificate https://'
end_uri='/'
result=$(wget -O- $add_uri$1$end_uri --post-data=$2)
flag=`echo $result|awk '{print match($0,"QC Domain")}'`;
echo $flag
echo "Nagios refreshes properly1"
if [[ $flag -gt 0 ]] ; then
echo 'ALL SEEMS FINE!!'
exit 0
else
echo 'Some Problem'
exit 2
fi;
When I execute this plugin directly from command line
./check_nhttps <url here> '<very long post data with credential information>'
The plugin works as expected(For both + & - test cases) and there seems to be no issues.
But when the plugin runs from Nagios,
check_command check_nhttps! <url here> '<very long post data with credential information>'
It always shows critical error(Prints else condition text "Some Problem" too).
P.S : Tried sending the post data with double quotes also.
Please help!!!
I'd think its very probable that your post data contains some characters that confuse nagios, maybe a space, or even a !. Better put the post data into some file and use --post-file. Also, you might insert echo "$2" > /tmp/this_is_my_post_data_when_executed_by_nagios into your script and check if the post data is ok.

Status for connector session is: 1544 Message: Code # 0 Connector Message: Error: Cannot find Connector 'DB2'

I have a database with two agents, well there are really more than two, but two that matter right now. One works, the other does not. Both have Uselsx '*lsxlc' defined in (Options).
I have commented out everything in the failing agent except
Dim s As New NotesSession
Dim db As NotesDatabase
Dim agentLog As NotesLog
Set db = s.CurrentDatabase
'agent log
Set agentLog = New NotesLog("Customers from Aging Report - AKM")
Call agentLog.OpenNotesLog( db.server, "agentinfo.nsf" )
agentLog.LogActions = True 'Set to True/False to turn on/off action logging
agentLog.LogErrors = True 'Set to True/False to turn on/off error logging
Call agentLog.LogAction("Start Agent: GetCustomerDataBasedOnAging")
On Error Goto throwError
Dim lcses As New LCSession
Dim src As New LCConnection(COutConn)
%REM
....
%END REM
Exit Sub
throwError:
'Error code
Dim epos As String
Dim emsg As String
Dim msg As String
Dim result As String
Dim status As Integer
Dim msgcode As Long
If lcses.status <> LCSUCCESS Then
status = lcses.GetStatus (result, msgcode, msg)
Call agentLog.LogError( msgcode,"Status for connector session is: " & Cstr(status) & Chr(10) & "Message: " & msg & " Code # " & Cstr(msgcode) & Chr(10) & "Connector Message: " & result )
emsg = "Customers from Aging Report' Agent: ("+Cstr(Erl)+") "& "[" &Cstr(Err) & "] [" & Error$ & "]"
Call agentLog.LogError( Err, emsg)
Else
emsg = "Customers from Aging Report' Agent: ("+Cstr(Erl)+") "& "[" &Cstr(Err) & "] [" & Error$ & "]"
Call agentLog.LogError( Err, emsg)
End If
Resume Next
COutConn is defined as a constant with value 'DB2'
I get the following error in the agent log:
Status for connector session is: 1544
Message: Code # 0
Connector Message: Error: Cannot find Connector 'DB2'
This happens whether I use the constant COutConn, or "DB2".
The strange thing is that the other agent with the same definitions works properly. I know DB2 exists on the machine, it is i5/OS v5r4. DB2 is built in on this operating system.
What else do I need to look for?
The answer is, be sure you know which machine the agent is running on. When you right click the agent in Domino Designer, and select Run, as I did, the agent is not running on the server that the database resides on, but rather inside the Domino Designer client. that is going to be Windows or Linux depending on your workstation.
So why did the one agent work while the other did not? Well the one that worked was activated from a button in the Notes Client, and the function attached to the button used Run on Server. The server was indeed IBM i. However, in the case of the failing agent, I executed that one from within Domino Designer as mentioned above, thus no DB2 connector.
Here's to hoping someone can learn from my pain!