Swagger 2.0 uploading a file to SP Online that doesn't send the extra content through












0














I'm hoping someone can point out my mistake here.
I have the following swagger definition which I use on swaggerhub that will upload a file to Sharepoint document library via the rest api



{
"swagger" : "2.0",
"info" : {
"description" : "defaultDescription",
"version" : "2",
"title" : "defaultTitle"
},
"host" : "someSite.sharepoint.com",
"schemes" : [ "https" ],
"paths" : {
"/sites/ms/_api/Web/GetFolderByServerRelativeUrl('doc/test/tt')/Files/Add(url='{filename}',overwrite=true)" : {
"post" : {
"consumes" : [ "multipart/form-data" ],
"produces" : [ "application/json" ],
"parameters" : [ {
"in" : "formData",
"name" : "upfile",
"type" : "file",
"required" : true,
"description" : "The file to upload."
},
{
"in" : "path",
"name" : "filename",
"type" : "string",
"required" : true
} ],
"responses" : {
"200" : {
"schema" : {
"type" : "string"
},
"description" : "Definition generated from Swagger Inspector"
}
}
}
}
}
}


Problem is I can't open any files on SP because they're broken, and I believe I found the reason when I tested with a txt file.



I'll send a text file only containing Sample text bu when I open it on SP doc library it contains all the following as well



-------------------------------28947758029299
Content-Disposition: form-data; name="upfile"; filename="myt.txt"
Content-Type: text/plain

Sample text
-------------------------------28947758029299--


Is the issue with my content type or should I use the parameter differently, I tried researching this but what I found just matched the original guid I found
https://swagger.io/docs/specification/2-0/file-upload/










share|improve this question






















  • In what format does your Sharepoint API expects the file? HTTP protocol has several ways to upload files, multipart/form-data is just one of them, but it's probably not what Sharepoint expects.
    – Helen
    Nov 19 '18 at 15:11










  • If I use postman to upload the I see the file being sent with content-type textplain and the file works once I try to open it SP side, but when I try to build the swagger with that as consume the swaggerhub throws an error: "Operations with parameters of "type: file" must include "multipart/form-data" in their "consumes" property" The SP documentation didn't specify what the content-type is supposed to be
    – Domitius
    Nov 20 '18 at 21:43
















0














I'm hoping someone can point out my mistake here.
I have the following swagger definition which I use on swaggerhub that will upload a file to Sharepoint document library via the rest api



{
"swagger" : "2.0",
"info" : {
"description" : "defaultDescription",
"version" : "2",
"title" : "defaultTitle"
},
"host" : "someSite.sharepoint.com",
"schemes" : [ "https" ],
"paths" : {
"/sites/ms/_api/Web/GetFolderByServerRelativeUrl('doc/test/tt')/Files/Add(url='{filename}',overwrite=true)" : {
"post" : {
"consumes" : [ "multipart/form-data" ],
"produces" : [ "application/json" ],
"parameters" : [ {
"in" : "formData",
"name" : "upfile",
"type" : "file",
"required" : true,
"description" : "The file to upload."
},
{
"in" : "path",
"name" : "filename",
"type" : "string",
"required" : true
} ],
"responses" : {
"200" : {
"schema" : {
"type" : "string"
},
"description" : "Definition generated from Swagger Inspector"
}
}
}
}
}
}


Problem is I can't open any files on SP because they're broken, and I believe I found the reason when I tested with a txt file.



I'll send a text file only containing Sample text bu when I open it on SP doc library it contains all the following as well



-------------------------------28947758029299
Content-Disposition: form-data; name="upfile"; filename="myt.txt"
Content-Type: text/plain

Sample text
-------------------------------28947758029299--


Is the issue with my content type or should I use the parameter differently, I tried researching this but what I found just matched the original guid I found
https://swagger.io/docs/specification/2-0/file-upload/










share|improve this question






















  • In what format does your Sharepoint API expects the file? HTTP protocol has several ways to upload files, multipart/form-data is just one of them, but it's probably not what Sharepoint expects.
    – Helen
    Nov 19 '18 at 15:11










  • If I use postman to upload the I see the file being sent with content-type textplain and the file works once I try to open it SP side, but when I try to build the swagger with that as consume the swaggerhub throws an error: "Operations with parameters of "type: file" must include "multipart/form-data" in their "consumes" property" The SP documentation didn't specify what the content-type is supposed to be
    – Domitius
    Nov 20 '18 at 21:43














0












0








0


1





I'm hoping someone can point out my mistake here.
I have the following swagger definition which I use on swaggerhub that will upload a file to Sharepoint document library via the rest api



{
"swagger" : "2.0",
"info" : {
"description" : "defaultDescription",
"version" : "2",
"title" : "defaultTitle"
},
"host" : "someSite.sharepoint.com",
"schemes" : [ "https" ],
"paths" : {
"/sites/ms/_api/Web/GetFolderByServerRelativeUrl('doc/test/tt')/Files/Add(url='{filename}',overwrite=true)" : {
"post" : {
"consumes" : [ "multipart/form-data" ],
"produces" : [ "application/json" ],
"parameters" : [ {
"in" : "formData",
"name" : "upfile",
"type" : "file",
"required" : true,
"description" : "The file to upload."
},
{
"in" : "path",
"name" : "filename",
"type" : "string",
"required" : true
} ],
"responses" : {
"200" : {
"schema" : {
"type" : "string"
},
"description" : "Definition generated from Swagger Inspector"
}
}
}
}
}
}


Problem is I can't open any files on SP because they're broken, and I believe I found the reason when I tested with a txt file.



I'll send a text file only containing Sample text bu when I open it on SP doc library it contains all the following as well



-------------------------------28947758029299
Content-Disposition: form-data; name="upfile"; filename="myt.txt"
Content-Type: text/plain

Sample text
-------------------------------28947758029299--


Is the issue with my content type or should I use the parameter differently, I tried researching this but what I found just matched the original guid I found
https://swagger.io/docs/specification/2-0/file-upload/










share|improve this question













I'm hoping someone can point out my mistake here.
I have the following swagger definition which I use on swaggerhub that will upload a file to Sharepoint document library via the rest api



{
"swagger" : "2.0",
"info" : {
"description" : "defaultDescription",
"version" : "2",
"title" : "defaultTitle"
},
"host" : "someSite.sharepoint.com",
"schemes" : [ "https" ],
"paths" : {
"/sites/ms/_api/Web/GetFolderByServerRelativeUrl('doc/test/tt')/Files/Add(url='{filename}',overwrite=true)" : {
"post" : {
"consumes" : [ "multipart/form-data" ],
"produces" : [ "application/json" ],
"parameters" : [ {
"in" : "formData",
"name" : "upfile",
"type" : "file",
"required" : true,
"description" : "The file to upload."
},
{
"in" : "path",
"name" : "filename",
"type" : "string",
"required" : true
} ],
"responses" : {
"200" : {
"schema" : {
"type" : "string"
},
"description" : "Definition generated from Swagger Inspector"
}
}
}
}
}
}


Problem is I can't open any files on SP because they're broken, and I believe I found the reason when I tested with a txt file.



I'll send a text file only containing Sample text bu when I open it on SP doc library it contains all the following as well



-------------------------------28947758029299
Content-Disposition: form-data; name="upfile"; filename="myt.txt"
Content-Type: text/plain

Sample text
-------------------------------28947758029299--


Is the issue with my content type or should I use the parameter differently, I tried researching this but what I found just matched the original guid I found
https://swagger.io/docs/specification/2-0/file-upload/







rest swagger-2.0






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 '18 at 14:09









Domitius

158314




158314












  • In what format does your Sharepoint API expects the file? HTTP protocol has several ways to upload files, multipart/form-data is just one of them, but it's probably not what Sharepoint expects.
    – Helen
    Nov 19 '18 at 15:11










  • If I use postman to upload the I see the file being sent with content-type textplain and the file works once I try to open it SP side, but when I try to build the swagger with that as consume the swaggerhub throws an error: "Operations with parameters of "type: file" must include "multipart/form-data" in their "consumes" property" The SP documentation didn't specify what the content-type is supposed to be
    – Domitius
    Nov 20 '18 at 21:43


















  • In what format does your Sharepoint API expects the file? HTTP protocol has several ways to upload files, multipart/form-data is just one of them, but it's probably not what Sharepoint expects.
    – Helen
    Nov 19 '18 at 15:11










  • If I use postman to upload the I see the file being sent with content-type textplain and the file works once I try to open it SP side, but when I try to build the swagger with that as consume the swaggerhub throws an error: "Operations with parameters of "type: file" must include "multipart/form-data" in their "consumes" property" The SP documentation didn't specify what the content-type is supposed to be
    – Domitius
    Nov 20 '18 at 21:43
















In what format does your Sharepoint API expects the file? HTTP protocol has several ways to upload files, multipart/form-data is just one of them, but it's probably not what Sharepoint expects.
– Helen
Nov 19 '18 at 15:11




In what format does your Sharepoint API expects the file? HTTP protocol has several ways to upload files, multipart/form-data is just one of them, but it's probably not what Sharepoint expects.
– Helen
Nov 19 '18 at 15:11












If I use postman to upload the I see the file being sent with content-type textplain and the file works once I try to open it SP side, but when I try to build the swagger with that as consume the swaggerhub throws an error: "Operations with parameters of "type: file" must include "multipart/form-data" in their "consumes" property" The SP documentation didn't specify what the content-type is supposed to be
– Domitius
Nov 20 '18 at 21:43




If I use postman to upload the I see the file being sent with content-type textplain and the file works once I try to open it SP side, but when I try to build the swagger with that as consume the swaggerhub throws an error: "Operations with parameters of "type: file" must include "multipart/form-data" in their "consumes" property" The SP documentation didn't specify what the content-type is supposed to be
– Domitius
Nov 20 '18 at 21:43












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376439%2fswagger-2-0-uploading-a-file-to-sp-online-that-doesnt-send-the-extra-content-th%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376439%2fswagger-2-0-uploading-a-file-to-sp-online-that-doesnt-send-the-extra-content-th%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]