Hi NickW,
Will it be possibl to upload the log file here for me to have a look at please, it would be great to see the error and the other details in reference to the error as well.
Kind regards,
Percy
Hi,
Have you solved your issue with the SharePoint REST API on SharePoint 2013? I'm trying to do the same but encountered errors. If I GET the SharePoint site title using API call http://dlp-wss/docwebsite/_api/web/title (with "Accept: application/json;odata=verbose" in the header to get the data in JSON format), I get:
{
"d": {
"Title": "My Site Title"
}
}
I created a swagger file, created the service instance and the smartobjects. However, when I execute the smartobject I get the following error message:
"10702 An error occurred in the sp_title Service Instance. Encountered a problem calling REST service. (Inner: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.)"
Content of the swagger file below. I must say, I'm a bit struggling with the authentication mode in the service instance.
Thanks
{
"swagger": "2.0",
"info": {
"title": "SharePoint API",
"description": "SharePoint API to get site title",
"version": "1.0"
},
"host": "dlp-wss",
"basePath": "/docwebsite/_api",
"schemes": u"http"],
"paths": {
"/web/title" : {
"get": {
"description": "Title",
"produces": u"application/json"],
"parameters":q
{"name":"Accept", "in":"header", "required":true, "default":"application/json;odata=verbose", "type":"string"}
],
"responses": {"200": {"description": "OK", "schema": {"$ref": "#/definitions/Document"}}},
}
}
},
"definitions": {
"Document": {
"properties": {
"d": {"$ref": "#/definitions/D"}}
},
"D": {
"properties": {
"Title": {"type": "string"}}
}
}
}
For the record and if this can help someone else, I managed to make it work. Basically, the REST broker doesn't support parameters of type header as explained here. This is why the Accept: application/json;odata=verbose defined in the swagger file was not taken into account. The API call returns XML data. Hence the issue with the parsing value: <.
The solution was to add the Default HTTP Request Headers in the Service Instance:
{"$type":"SourceCode.SmartObjects.Services.Endpoints.Common.HttpHeader[], SourceCode.SmartObjects.Services.Endpoints.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null","$values":[{"$type":"SourceCode.SmartObjects.Services.Endpoints.Common.HttpHeader, SourceCode.SmartObjects.Services.Endpoints.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null","Name":"Accept","Value":"application/json;odata=verbose"}]}
Service Instance definition:
I'm now trying to upload a file to SharePoint using the REST API and I have an issue with the contents of the file.
1) I created a first REST Service Instance to obtain the FormDigestValue required by the API. See Writing data by using the REST interface at Complete basic operations using SharePoint REST endpoints. The swagger file is spContextInfoOlaf.json. And the definition of the Service Instance:
2) I created a second Service Instance to create the SharePoint file. The swagger file is spFileAddOlaf.json. I used the technique for File Parameters described in the article REST Swagger File Reference Format. And the Service Instance definition:
At this stage, I inserted manually the FormDigestValue returned by the first API call in the http header (value of X-RequestDigest). This needs to be changed each time because the FormDigestValue seems to have a limited life.
{"$type": "SourceCode.SmartObjects.Services.Endpoints.Common.HttpHeader[], SourceCode.SmartObjects.Services.Endpoints.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null","$values": [{"$type": "SourceCode.SmartObjects.Services.Endpoints.Common.HttpHeader, SourceCode.SmartObjects.Services.Endpoints.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null","Name": "X-RequestDigest","Value": "0xA510B2E9D3908E56EBC5BB2F74380D32B2A9D1873B632AA734759F65194A700167E0573FAAD84B2A40D675D3061A8DFFBEDD7791AB7D500808E97CC25538EB80,14 Mar 20*personal details removed*:56:57 -0000"},{"$type": "SourceCode.SmartObjects.Services.Endpoints.Common.HttpHeader, SourceCode.SmartObjects.Services.Endpoints.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null","Name": "Accept","Value": "application/json;odata=verbose"},{"$type": "SourceCode.SmartObjects.Services.Endpoints.Common.HttpHeader, SourceCode.SmartObjects.Services.Endpoints.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null", "Name": "Content-Type","Value": "application/x-www-form-urlencoded"}]}
I uploaded the attached text file abcd.txt (it contains the text "abcd"). The file is uploaded to SharePoint but the issue is that it contains additional contents as shown below. Any idea on how to get rid of these contents and only have the contents of the original file?
-------------------------------28947758029299
Content-Disposition: form-data; name="file"; filename="abcd.txt"
Content-Type: text/plain
abcd
-------------------------------28947758029299--
Did my homework and this is the normal behaviour when using multipart/form-data as described here https://ec.haxx.se/http-multipart.html e.g.
--------------------------d74496d66958873e
Content-Disposition: form-data; name="secret"; filename="file.txt"
Content-Type: text/plain
contents of the file
--------------------------d74496d66958873e--
So this basically won't work as the SharePoint API expects the contents of the file in the body. Hum...
Hi,
although I know this is quite a old thread but I struggeling with exactly the same issue as @Ferko described in the solution. But besides I also added the Default HTTP Request Headers pointed out there I still get that following error:
I even changed the swagger file to accept xml but I still get that error.
BTW: I try to connect the SAP IDM v2 Rest-API and not sharepoint like @Ferko.
Anyone any idea what I can do?
thanks and regards,
Tim