本文介绍了SharePoint(Office 365)无法将文件上载到目录(从Linux计算机)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好,我正在尝试将文件从linux(centos)服务器上传到SharePoint。 我使用curl进行各种连接,如下所示。 在第一个curl操作中,我可以成功建立连接并获取身份验证令牌。 在第二个连接中,我可以成功建立连接并检索相关的安全令牌。 在第三个连接中,我可以成功检索两个cookie。 在最后一个连接中,我可以"成功"将文件上传到相应的目录,我得到一个"< HTTP / 1.1 100继续 *我们已完全上传且罚款通知。 $ 然后我得到一个"X-MSDAVEXT_Error:917656;" ; - HTTP / 1.1 403禁止通知。 这怎么可能,他告诉我一切进展顺利,上传文件后,我收到消息。 br />Hello, I am trying to upload a file from a linux (centos) server to SharePoint.I make various connections with curl as you can see below.In the first curl action I can successfully make a connection and obtain an authentication token.In the second connection I can successfully make a connection and retrieve the associated security token.In the third connection I can successfully retrieve both cookies.In the last connection I can 'successfully' upload the file to the corresponding directory, I get a "<HTTP / 1.1 100 Continue* We are completely uploaded and fine "notification.But then I get an "X-MSDAVEXT_Error: 917656;" - HTTP / 1.1 403 Forbidden notification.How is this possible, he tells me that everything is going well, and after uploading the file, I get the message.最终(第4次)卷曲如下所示:The final (4th) curl looks like this: curl -b cookies \ -H " X-RequestDigest: $ {DIGEST} " \ -H " 接受:application / json; odata = verbose " \ -H " 内容类型:multipart / form-data " \ -T " $ { 1} " \ -X POST " https://****.sharepoint.com / sites / $ {SITENAME} / _ api / web / GetFolderByServerRelativeUrl(' $ {3} ' )/ files / add(url =' $ {FILENAME} ',overwrite = true)"curl -b cookies \-H "X-RequestDigest:${DIGEST}" \-H "Accept: application/json;odata=verbose" \-H "Content-Type: multipart/form-data" \-T "${1}" \-X POST "https://****.sharepoint.com/sites/${SITENAME}/_api/web/GetFolderByServerRelativeUrl('${3}')/files/add(url='${FILENAME}',overwrite=true)"推荐答案以下解决方案供您参考。The following solution for your reference. 1.编辑auth.xml以添加您的用户帐户信息和域。1.Edit auth.xml to add your user account info and domain. auth.xml代码:auth.xml code:<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <s:Header> <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> <a:To s:mustUnderstand="1">https://login.microsoftonline.com/extSTS.srf</a:To> <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <o:UsernameToken> <o:Username>[ your user name ]</o:Username> <o:Password>[ your password ]</o:Password> </o:UsernameToken> </o:Security> </s:Header> <s:Body> <t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> <a:EndpointReference> <a:Address>https://[ you ].sharepoint.com/</a:Address> </a:EndpointReference> </wsp:AppliesTo> <t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType> <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType> <t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType> </t:RequestSecurityToken> </s:Body></s:Envelope> 2.编辑SharePoint_upload.sh以指向您的SP域。2.Edit SharePoint_upload.sh to point to your SP domain. SharePoint_upload.sh:SharePoint_upload.sh:SITENAME=" {2}" #XML dom解析自:#http://stackoverflow.com/questions/893585/how-to-parse-xml-in-bash read_dom(){ local IFS = \> read -d \< ENTITY CONTENT } #获取安全令牌 curl -X POST -d @ auth.xml https://login.microsoftonline.com/extSTS.srf -o rstoken #解析安全令牌响应(rstoken)而read_dom;如果[[{2}"# XML dom parsing from:# http://stackoverflow.com/questions/893585/how-to-parse-xml-in-bashread_dom () { local IFS=\> read -d \< ENTITY CONTENT}# Get the security tokencurl -X POST -d @auth.xml https://login.microsoftonline.com/extSTS.srf -o rstoken# Parse secure token response (rstoken)while read_dom; do if [[ ENTITY =" wsse:BinarySecurityToken Id = \" Compact0 \""" do ]];然后 echoENTITY = "wsse:BinarySecurityToken Id=\"Compact0\"" ]] ; then echo 这篇关于SharePoint(Office 365)无法将文件上载到目录(从Linux计算机)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-03 18:14