Set Excel / Word Online document readonly using Graph API - microsoft-graph-api

When an Excel or Word file on SharePoint is opened,it is in edit mode by default.From Excel/Word online menu, there is a menu option to set the file read-only, called "Protect Workbook" in Excel inline and "Protect Document" in Word online, as shown in the screenshot.
Next time the file is open in Excel/Word online, it is opened in read-only mode and shows an "Edit Anyway" button to switch to edit mode, which is exactly what I need.
Question is: How can I use Graph API to programatically set an Excel or Word document as read-only?

HTTP request
POST /workbook/worksheets/{id|name}/protection/protect
Request headers
Name Description
Authorization Bearer {token}. Required.
Workbook-Session-Id Workbook session Id that determines if changes are persisted or not. Optional.
Request body
In the request body, provide a JSON object with the following parameters.
Parameter Type Description
options WorkbookWorksheetProtectionOptions Optional. sheet protection options.
Response
If successful, this method returns 200 OK response code. It does not return anything in the response body.
Kindly look at https://learn.microsoft.com/en-us/graph/api/worksheetprotection-protect?view=graph-rest-1.0&tabs=http for more Information

Related

Why url params doesn't work in some sites?

I'm trying to add param in the url, like in this example:
https://www.google.com/ > https://www.google.com/search?q=qq
Opening the last link you can see "qq" in the "q" input.
For this site it doesn't work (this is the problem):
https://www.calabriasue.it/assistenza/richiesta-assistenza-e-supporto/
https://www.calabriasue.it/assistenza/richiesta-assistenza-e-supporto/?nome=mario
Can I add url param also in the last one? I need it.
Thanks!
I tried using different input names, different params ecc but it doesn't work.
Google's server side code is designed to generate an HTML document with an input field that is prefilled with the current search term which is reads from the URL. That is why adding q=search+term to the URL populates the input field.
You can't make arbitrary third-party websites prefill inputs. They have to explicitly provide a mechanism to make it possible.
Parameters only work as long as the code for the target website is expecting to handle a parameter named "nome" with a value "mario". In the case of the google website, it is expecting a parameter named "q" and has a form input for it.
Clicking a URL sends a a GET request type, and the target site may only be accepting parameters from a POST request type. You could consider using the application known as "PostMan" to help with that.
Alternately, the target page you are viewing may be forwarded / routed from a different page which accepts parameters.

Use VBScript to Parse a Webpage's Text

I'm currently working on a VBScript that will open multiple URLs in order to update documents on a server. I was wondering if there was a way to parse a webpage's content for a specific string, in this case being the updateResult SUCCESS line shown below:
I need to be able to record the success of this webpage text as opposed to the failure page below:
This is all that is on the webpage. How would I go about parsing the text of both these types of pages in order to know that the document has updated correctly or not?

url field is not getting recognised in Watson Discovery service during conversion

Inline with this thread
How do we get the document file url using the Watson Discovery Service?,
I tried adding url field inside HTML document under various tags like p, directly as
<"url">...<"/url"> etc inside <"body"> tag.
Whatever I do, this url field that I am trying to add is not getting reflected either under extracted_metadata or under html or under text in the json when I see the resulting json after conversion / enrichment in the discovery tooling. Can someone throw some hint on what I can do to get url field just like title under extracted_metadata section in the json output?

Zuora - How to get invoice PDF and display to user

Short question: Using the get_invoices endpoint, when I try to access the URL from the InvoiceFiles.pdfFileUrl response, it pops up a api.zuora login form. I need my customers to be able to access these PDFs.
If I enter my Zuora creds, it will display the invoice, but of course my customers don't have Zuora creds.
Is there some sort of setting to allow customers to view PDFs from the URL?
Long Question:
The get_invoices endpoint returns 2 items of interest.
body is the REST URL of the invoice PDF file.
and
InvoiceFiles returns
id ID of the invoice PDF file. This is the ID for the file object and different from the file handle id in the pdfFileUrl field. To open a file, you need to use the file handle ID.
versionNumber Version number of the invoice PDF file
pdfFileUrl REST URL for the invoice PDF file. Click the URL to open the invoice PDF file.
Is there a difference between what is returned by body and InvoiceFiles.pdfFileUrl, and how do I use them correctly?
The pdfFileUrl can return multiple files. Each time the invoice is update (the customer pays etc) it generates another file. The most recent is the at index 0.
However trying to access any of the URLs, I get a api.zuora login form. If I enter my Zuora creds, it will display the invoice, but of course my customers don't have Zuora creds.
The example on the endpoint page has both the body and the pdfFiles return as blank so that doesn't help much.
Searched through their community for a while, nothing couldn't find anything remotely similar to my issue.
We finally figured out how to do this. Has to be done server side.
First step was to call "/transactions/invoices/accounts/{accountId}" to get a list of invoices.
Second, pick the invoice out of the list that matched the invoice number we were trying to view.
On that object is a list called "invoiceFiles" - if it was non-empty, grab the first item.
Use the "pdfFileUrl" property on that item as the URL to fetch the PDF from, but in the GET request, include headers "apiAccessKeyId" and "apiSecretAccessKey" with the values set to our applicable api key. This eliminates the auth problem, but also makes it so you have to do this on your backend to avoid exposing your apiAccessKeyId and Secret.
Assuming the request for the PDF coming into us was authenticated, we'd do a pipe command on the response coming back from Zuora onto the outgoing response we are currently handling on our server: zuoraResponse.pipe(ourOutgoingResponseObj)
This will display the PDF directly to the user.
The best practice would be to use an authorization cookie. The cookie authorizes the user to make calls to the REST API for the duration specified in Administration > Security Policies > Session timeout in Zuora settings. The cookie expiration time is reset with this duration after every call to the REST API.
To obtain a cookie, call the REST connections resource:
curl -X POST \
-H "apiAccessKeyId: dummyUser" \
-H "apiSecretAccessKey: dummyPassword" \
-H "Content-Type: application/json" \
-d '{}' \
"https://rest.zuora.com/v1/connections"
Once the connection is established, subsequent API calls will work without the apiSecretAccessKey and apiAccessKeyId in the header.
Please find more details from their new API document.
https://www.zuora.com/developer/api-reference/

JIRA Tempo Plugin

I'm trying to use the API for JIRA's Tempo :
https://tempoplugin.jira.com/wiki/display/TEMPO/Tempo+Servlet+Manual#TempoServletManual-WorklogReport
specifically trying to get worklogs through the url:
http(s)://yourserver.yourdomain/plugins/servlet/tempo-getWorklog/?dateFrom=2011-01-01&dateTo=2011-01-31&format=xml&diffOnly=false&tempoApiToken=my-token
What should be the values for yourserver and yourdomain. if im testing on a localhost, is it 'localhost:port'? or is it the actual url for my account on jira, example: 'jira.companyname.com'? I'm using RestClient to make the request in my app.
It will be actual url for your account on jira. eg -
https://companyname.jira.com/plugins/servlet/tempo-getWorklog/?dateFrom=2014-04-21&dateTo=2014-04-27&format=xml&tempoApiToken=e4cd79c4-0457-42f3-bf29-6f3f0f5c8bcf&projectKey=project&addUserDetails=true&addIssueDetails=true&addWorklogDetails=true&addIssueSummary=true&addIssueDescription=false
The above url returns the result in xml format. Change the appended parameters according to your need. Make sure you enter the right tempoApiToken value (tempo administrator has this value).

Resources