I am using Spring Boot for storing files (of basically as many format as possible - but think along the lines of images, documents) in SharePoint for my application, which is deployed in SAP's Cloud Foundry. I have pretty much followed the steps mentioned in this post's answer (and copied all four files from there) and I got a github repo which pretty much implements the same thing. I've followed them but something is not working for me. (Please refer to the StackOverflow link for further reference of what I'm talking about)
The order of method calls in SharePointServiceCached.java is
parseExecutionDateTime() -> receiveSecurityToken() -> getSignInCookies(securityToken) -> getFormDigestValue(cookies)
I receive the security token (as I checked from my logs) but this is the error message I'm getting:
Document upload failed!org.springframework.web.client.HttpClientErrorException$Forbidden: 403 Forbidden: [403 FORBIDDEN]
Things I have tried for this:
- Added SSL part (see code at end of lists) to the request which only seemed to made it worse.
- Added user agent to headers which made no difference.
- Changed the endpoint domain from
https://protected1.sharepoint.com/sites/protected2
to https://protected1.sharepoint.com/
which again, somehow made it worse. (Obviously, protected1 and protected2 are changed names)
- Made myself (the person whose credentials I'm passing) the owner of the site with all privileges.
- I checked the logs, the credentials are getting passed correctly.
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder)
{
CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier())
.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
RestTemplate rest = new RestTemplate(requestFactory);
builder.configure(rest);
return builder.build();
}
Also, previously I was using a CMS for the same thing which returned a document ID associated with the uploaded file. I have enabled the option for document IDs in SharePoint and want to use it similarly, i.e. upload a file -> get a document ID and store it -> use that document ID to fetch the file when required. How can I do this?
Thank you in advance.
question from:
https://stackoverflow.com/questions/66052843/use-sharepoint-as-a-kind-of-cms-using-spring-boot 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…