You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openmeetings.apache.org by "K. Kamhamea" <ka...@googlemail.com> on 2020/04/28 12:06:05 UTC

REST API to upload file

Has anyone successfully used file upload with WebServices. I always get an
HTTP 415 error.
And of course I used headers

'Content-type': "multipart/form-data"


There is a discrepancy in the documentation.
While
http://openmeetings.apache.org/openmeetings-webservice/apidocs/org/apache/openmeetings/webservice/FileWebService.html
says there are 3 parameters necessary
The xml documentation lists only two sid and stream












*   <resource path="/file">      <method name="POST">         <request>
        <param name="sid" style="query" type="xs:string" />
<representation mediaType="multipart/form-data">               <param
name="stream" style="query" type="xs:anyType" />
</representation>         </request>         <response>
<representation mediaType="application/json" />         </response>
</method>*

Also the parameter name 'steam' is not accepted at all, as I get an 400 or
500 error. If I send the stream by the name 'file', as usual, I get 415.

Unfortunately the catalina.out file doesn't report much more information.

Re: REST API to upload file

Posted by "K. Kamhamea" <ka...@googlemail.com>.
I cannot find a search function.

Am Mi., 29. Apr. 2020 um 07:42 Uhr schrieb Maxim Solodovnik <
solomax666@gmail.com>:

> ML == mailing lists
> https://openmeetings.apache.org/mailing-lists.html
>
> On Wed, 29 Apr 2020 at 12:41, K. Kamhamea <ka...@googlemail.com> wrote:
> >
> > Waht is " ML archives " ?
> >
> > Am Mi., 29. Apr. 2020 um 03:47 Uhr schrieb Maxim Solodovnik <
> solomax666@gmail.com>:
> >>
> >> On Tue, 28 Apr 2020 at 23:20, K. Kamhamea <ka...@googlemail.com>
> wrote:
> >> >
> >> > Does the file upload with moodle really work? I doubt so, as header
> and body in my requests look almost the same no matter which software I use
> to generate it.
> >>
> >> Yes
> >>
> >> >
> >> > Is it possible that it depends on the content of the fileDTO? What
> fields are required in that structure.
> >>
> >> No
> >>
> >> >
> >> > Also can I turn some debug on, so the server will print more detailed
> information about the cause of the error?
> >>
> >> Yes
> >> Please search ML archives :)
> >>
> >> >
> >> > Am Di., 28. Apr. 2020 um 14:42 Uhr schrieb Maxim Solodovnik <
> solomax666@gmail.com>:
> >> >>
> >> >> Please check sources for moodle plugin
> >> >>
> >> >> On Tue, Apr 28, 2020, 19:06 K. Kamhamea <ka...@googlemail.com>
> wrote:
> >> >>>
> >> >>> Has anyone successfully used file upload with WebServices. I always
> get an HTTP 415 error.
> >> >>> And of course I used headers
> >> >>>
> >> >>> 'Content-type': "multipart/form-data"
> >> >>>
> >> >>>
> >> >>> There is a discrepancy in the documentation.
> >> >>> While
> >> >>>
> http://openmeetings.apache.org/openmeetings-webservice/apidocs/org/apache/openmeetings/webservice/FileWebService.html
> >> >>> says there are 3 parameters necessary
> >> >>> The xml documentation lists only two sid and stream
> >> >>>
> >> >>>    <resource path="/file">
> >> >>>       <method name="POST">
> >> >>>          <request>
> >> >>>             <param name="sid" style="query" type="xs:string" />
> >> >>>             <representation mediaType="multipart/form-data">
> >> >>>                <param name="stream" style="query" type="xs:anyType"
> />
> >> >>>             </representation>
> >> >>>          </request>
> >> >>>          <response>
> >> >>>             <representation mediaType="application/json" />
> >> >>>          </response>
> >> >>>       </method>
> >> >>>
> >> >>> Also the parameter name 'steam' is not accepted at all, as I get an
> 400 or 500 error. If I send the stream by the name 'file', as usual, I get
> 415.
> >> >>>
> >> >>> Unfortunately the catalina.out file doesn't report much more
> information.
> >> >>>
> >> >>>
> >> >>>
> >>
> >>
> >> --
> >> Best regards,
> >> Maxim
>
>
>
> --
> Best regards,
> Maxim
>

Re: REST API to upload file

Posted by Maxim Solodovnik <so...@gmail.com>.
ML == mailing lists
https://openmeetings.apache.org/mailing-lists.html

On Wed, 29 Apr 2020 at 12:41, K. Kamhamea <ka...@googlemail.com> wrote:
>
> Waht is " ML archives " ?
>
> Am Mi., 29. Apr. 2020 um 03:47 Uhr schrieb Maxim Solodovnik <so...@gmail.com>:
>>
>> On Tue, 28 Apr 2020 at 23:20, K. Kamhamea <ka...@googlemail.com> wrote:
>> >
>> > Does the file upload with moodle really work? I doubt so, as header and body in my requests look almost the same no matter which software I use to generate it.
>>
>> Yes
>>
>> >
>> > Is it possible that it depends on the content of the fileDTO? What fields are required in that structure.
>>
>> No
>>
>> >
>> > Also can I turn some debug on, so the server will print more detailed information about the cause of the error?
>>
>> Yes
>> Please search ML archives :)
>>
>> >
>> > Am Di., 28. Apr. 2020 um 14:42 Uhr schrieb Maxim Solodovnik <so...@gmail.com>:
>> >>
>> >> Please check sources for moodle plugin
>> >>
>> >> On Tue, Apr 28, 2020, 19:06 K. Kamhamea <ka...@googlemail.com> wrote:
>> >>>
>> >>> Has anyone successfully used file upload with WebServices. I always get an HTTP 415 error.
>> >>> And of course I used headers
>> >>>
>> >>> 'Content-type': "multipart/form-data"
>> >>>
>> >>>
>> >>> There is a discrepancy in the documentation.
>> >>> While
>> >>> http://openmeetings.apache.org/openmeetings-webservice/apidocs/org/apache/openmeetings/webservice/FileWebService.html
>> >>> says there are 3 parameters necessary
>> >>> The xml documentation lists only two sid and stream
>> >>>
>> >>>    <resource path="/file">
>> >>>       <method name="POST">
>> >>>          <request>
>> >>>             <param name="sid" style="query" type="xs:string" />
>> >>>             <representation mediaType="multipart/form-data">
>> >>>                <param name="stream" style="query" type="xs:anyType" />
>> >>>             </representation>
>> >>>          </request>
>> >>>          <response>
>> >>>             <representation mediaType="application/json" />
>> >>>          </response>
>> >>>       </method>
>> >>>
>> >>> Also the parameter name 'steam' is not accepted at all, as I get an 400 or 500 error. If I send the stream by the name 'file', as usual, I get 415.
>> >>>
>> >>> Unfortunately the catalina.out file doesn't report much more information.
>> >>>
>> >>>
>> >>>
>>
>>
>> --
>> Best regards,
>> Maxim



-- 
Best regards,
Maxim

Re: REST API to upload file

Posted by "K. Kamhamea" <ka...@googlemail.com>.
 This is headers and body of sending a one pixel transparent png image that
triggers an 415 response.

'body': b'--668f009a1a08af558360542449ab33d1\r\nContent-Disposition:
form-da'
          b'ta; name="file"\r\n\r\n{"ownerId": 12, "name": "spacer.png",
"ro'
          b'omId": 50, "externalType": "WebCMS", "externalId": "G25",
"type"'
          b':
"Image"}\r\n--668f009a1a08af558360542449ab33d1\r\nContent-Disp'
          b'osition: form-data; name="stream";
filename="spacer.png"\r\nConten'
          b't-Type: application/octet-stream\r\n\r\n\x89PNG\r\n\x1a\n'

b'\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x04\x00\x00'

b'\x00\xb5\x1c\x0c\x02\x00\x00\x00\x04gAMA\x00\x00\xaf\xc87\x05\x8a'
          b'\xe9\x00\x00\x00\x0bIDAT\x08\xd7c``\x00\x00\x00\x03\x00\x01'
          b'
\xd5\x94\xc7\x00\x00\x00\x00IEND\xaeB`\x82\r\n--668f009a1a08af55'
          b'8360542449ab33d1--\r\n',
  'headers': {'Content-Length': '472', 'Content-Type':
'multipart/form-data; boundary=668f009a1a08af558360542449ab33
d1'},

If I add an "Content-Type: application/json" to the body's fileDTO part as
the moodle plugin would do. I get a 400 response.


  'body': b'--8ec1f812815cd9e98b34312c6d1a6d52\r\nContent-Disposition:
form-da'
          b'ta; name="file"\r\nContent-Type:
application/json\r\n\r\n{"ownerId'
          b'": 12, "name": "spacer.png", "roomId": 50, "externalType":
"WebC'
          b'MS", "externalId": "G25", "type":
"Image"}\r\n--8ec1f812815cd9e98b'
          b'34312c6d1a6d52\r\nContent-Disposition: form-data;
name="stream"; f'
          b'ilename="spacer.png"\r\nContent-Type: application/octet-stream'
          b'\r\n\r\n\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01'

b'\x00\x00\x00\x01\x08\x04\x00\x00\x00\xb5\x1c\x0c\x02\x00\x00\x00'

b'\x04gAMA\x00\x00\xaf\xc87\x05\x8a\xe9\x00\x00\x00\x0bIDAT\x08\xd7c'
          b'``\x00\x00\x00\x03\x00\x01 \xd5\x94\xc7\x00\x00\x00\x00IEND'
          b'\xaeB`\x82\r\n--8ec1f812815cd9e98b34312c6d1a6d52--\r\n',
  'headers': {'Content-Length': '504', 'Content-Type':
'multipart/form-data; boundary=8ec1f812815cd9e98b34312c6d1a6d
52'},

Can someone send me such a minimalized headers body combination that
actually works to test my system?

Best K


Am Mi., 29. Apr. 2020 um 07:40 Uhr schrieb K. Kamhamea <
kamhamea@googlemail.com>:

> Waht is " ML archives " ?
>
> Am Mi., 29. Apr. 2020 um 03:47 Uhr schrieb Maxim Solodovnik <
> solomax666@gmail.com>:
>
>> On Tue, 28 Apr 2020 at 23:20, K. Kamhamea <ka...@googlemail.com>
>> wrote:
>> >
>> > Does the file upload with moodle really work? I doubt so, as header and
>> body in my requests look almost the same no matter which software I use to
>> generate it.
>>
>> Yes
>>
>> >
>> > Is it possible that it depends on the content of the fileDTO? What
>> fields are required in that structure.
>>
>> No
>>
>> >
>> > Also can I turn some debug on, so the server will print more detailed
>> information about the cause of the error?
>>
>> Yes
>> Please search ML archives :)
>>
>> >
>> > Am Di., 28. Apr. 2020 um 14:42 Uhr schrieb Maxim Solodovnik <
>> solomax666@gmail.com>:
>> >>
>> >> Please check sources for moodle plugin
>> >>
>> >> On Tue, Apr 28, 2020, 19:06 K. Kamhamea <ka...@googlemail.com>
>> wrote:
>> >>>
>> >>> Has anyone successfully used file upload with WebServices. I always
>> get an HTTP 415 error.
>> >>> And of course I used headers
>> >>>
>> >>> 'Content-type': "multipart/form-data"
>> >>>
>> >>>
>> >>> There is a discrepancy in the documentation.
>> >>> While
>> >>>
>> http://openmeetings.apache.org/openmeetings-webservice/apidocs/org/apache/openmeetings/webservice/FileWebService.html
>> >>> says there are 3 parameters necessary
>> >>> The xml documentation lists only two sid and stream
>> >>>
>> >>>    <resource path="/file">
>> >>>       <method name="POST">
>> >>>          <request>
>> >>>             <param name="sid" style="query" type="xs:string" />
>> >>>             <representation mediaType="multipart/form-data">
>> >>>                <param name="stream" style="query" type="xs:anyType" />
>> >>>             </representation>
>> >>>          </request>
>> >>>          <response>
>> >>>             <representation mediaType="application/json" />
>> >>>          </response>
>> >>>       </method>
>> >>>
>> >>> Also the parameter name 'steam' is not accepted at all, as I get an
>> 400 or 500 error. If I send the stream by the name 'file', as usual, I get
>> 415.
>> >>>
>> >>> Unfortunately the catalina.out file doesn't report much more
>> information.
>> >>>
>> >>>
>> >>>
>>
>>
>> --
>> Best regards,
>> Maxim
>>
>

Re: REST API to upload file

Posted by "K. Kamhamea" <ka...@googlemail.com>.
Waht is " ML archives " ?

Am Mi., 29. Apr. 2020 um 03:47 Uhr schrieb Maxim Solodovnik <
solomax666@gmail.com>:

> On Tue, 28 Apr 2020 at 23:20, K. Kamhamea <ka...@googlemail.com> wrote:
> >
> > Does the file upload with moodle really work? I doubt so, as header and
> body in my requests look almost the same no matter which software I use to
> generate it.
>
> Yes
>
> >
> > Is it possible that it depends on the content of the fileDTO? What
> fields are required in that structure.
>
> No
>
> >
> > Also can I turn some debug on, so the server will print more detailed
> information about the cause of the error?
>
> Yes
> Please search ML archives :)
>
> >
> > Am Di., 28. Apr. 2020 um 14:42 Uhr schrieb Maxim Solodovnik <
> solomax666@gmail.com>:
> >>
> >> Please check sources for moodle plugin
> >>
> >> On Tue, Apr 28, 2020, 19:06 K. Kamhamea <ka...@googlemail.com>
> wrote:
> >>>
> >>> Has anyone successfully used file upload with WebServices. I always
> get an HTTP 415 error.
> >>> And of course I used headers
> >>>
> >>> 'Content-type': "multipart/form-data"
> >>>
> >>>
> >>> There is a discrepancy in the documentation.
> >>> While
> >>>
> http://openmeetings.apache.org/openmeetings-webservice/apidocs/org/apache/openmeetings/webservice/FileWebService.html
> >>> says there are 3 parameters necessary
> >>> The xml documentation lists only two sid and stream
> >>>
> >>>    <resource path="/file">
> >>>       <method name="POST">
> >>>          <request>
> >>>             <param name="sid" style="query" type="xs:string" />
> >>>             <representation mediaType="multipart/form-data">
> >>>                <param name="stream" style="query" type="xs:anyType" />
> >>>             </representation>
> >>>          </request>
> >>>          <response>
> >>>             <representation mediaType="application/json" />
> >>>          </response>
> >>>       </method>
> >>>
> >>> Also the parameter name 'steam' is not accepted at all, as I get an
> 400 or 500 error. If I send the stream by the name 'file', as usual, I get
> 415.
> >>>
> >>> Unfortunately the catalina.out file doesn't report much more
> information.
> >>>
> >>>
> >>>
>
>
> --
> Best regards,
> Maxim
>

Re: REST API to upload file

Posted by Maxim Solodovnik <so...@gmail.com>.
On Tue, 28 Apr 2020 at 23:20, K. Kamhamea <ka...@googlemail.com> wrote:
>
> Does the file upload with moodle really work? I doubt so, as header and body in my requests look almost the same no matter which software I use to generate it.

Yes

>
> Is it possible that it depends on the content of the fileDTO? What fields are required in that structure.

No

>
> Also can I turn some debug on, so the server will print more detailed information about the cause of the error?

Yes
Please search ML archives :)

>
> Am Di., 28. Apr. 2020 um 14:42 Uhr schrieb Maxim Solodovnik <so...@gmail.com>:
>>
>> Please check sources for moodle plugin
>>
>> On Tue, Apr 28, 2020, 19:06 K. Kamhamea <ka...@googlemail.com> wrote:
>>>
>>> Has anyone successfully used file upload with WebServices. I always get an HTTP 415 error.
>>> And of course I used headers
>>>
>>> 'Content-type': "multipart/form-data"
>>>
>>>
>>> There is a discrepancy in the documentation.
>>> While
>>> http://openmeetings.apache.org/openmeetings-webservice/apidocs/org/apache/openmeetings/webservice/FileWebService.html
>>> says there are 3 parameters necessary
>>> The xml documentation lists only two sid and stream
>>>
>>>    <resource path="/file">
>>>       <method name="POST">
>>>          <request>
>>>             <param name="sid" style="query" type="xs:string" />
>>>             <representation mediaType="multipart/form-data">
>>>                <param name="stream" style="query" type="xs:anyType" />
>>>             </representation>
>>>          </request>
>>>          <response>
>>>             <representation mediaType="application/json" />
>>>          </response>
>>>       </method>
>>>
>>> Also the parameter name 'steam' is not accepted at all, as I get an 400 or 500 error. If I send the stream by the name 'file', as usual, I get 415.
>>>
>>> Unfortunately the catalina.out file doesn't report much more information.
>>>
>>>
>>>


-- 
Best regards,
Maxim

Re: REST API to upload file

Posted by "K. Kamhamea" <ka...@googlemail.com>.
Does the file upload with moodle really work? I doubt so, as header and
body in my requests look almost the same no matter which software I use to
generate it.

Is it possible that it depends on the content of the fileDTO? What fields
are required in that structure.

Also can I turn some debug on, so the server will print more detailed
information about the cause of the error?

Am Di., 28. Apr. 2020 um 14:42 Uhr schrieb Maxim Solodovnik <
solomax666@gmail.com>:

> Please check sources for moodle plugin
>
> On Tue, Apr 28, 2020, 19:06 K. Kamhamea <ka...@googlemail.com> wrote:
>
>> Has anyone successfully used file upload with WebServices. I always get
>> an HTTP 415 error.
>> And of course I used headers
>>
>> 'Content-type': "multipart/form-data"
>>
>>
>> There is a discrepancy in the documentation.
>> While
>>
>> http://openmeetings.apache.org/openmeetings-webservice/apidocs/org/apache/openmeetings/webservice/FileWebService.html
>> says there are 3 parameters necessary
>> The xml documentation lists only two sid and stream
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *   <resource path="/file">      <method name="POST">         <request>
>>           <param name="sid" style="query" type="xs:string" />
>> <representation mediaType="multipart/form-data">               <param
>> name="stream" style="query" type="xs:anyType" />
>> </representation>         </request>         <response>
>> <representation mediaType="application/json" />         </response>
>> </method>*
>>
>> Also the parameter name 'steam' is not accepted at all, as I get an 400
>> or 500 error. If I send the stream by the name 'file', as usual, I get 415.
>>
>> Unfortunately the catalina.out file doesn't report much more information.
>>
>>
>>
>>

Re: REST API to upload file

Posted by Maxim Solodovnik <so...@gmail.com>.
Please check sources for moodle plugin

On Tue, Apr 28, 2020, 19:06 K. Kamhamea <ka...@googlemail.com> wrote:

> Has anyone successfully used file upload with WebServices. I always get an
> HTTP 415 error.
> And of course I used headers
>
> 'Content-type': "multipart/form-data"
>
>
> There is a discrepancy in the documentation.
> While
>
> http://openmeetings.apache.org/openmeetings-webservice/apidocs/org/apache/openmeetings/webservice/FileWebService.html
> says there are 3 parameters necessary
> The xml documentation lists only two sid and stream
>
>
>
>
>
>
>
>
>
>
>
>
> *   <resource path="/file">      <method name="POST">         <request>
>         <param name="sid" style="query" type="xs:string" />
> <representation mediaType="multipart/form-data">               <param
> name="stream" style="query" type="xs:anyType" />
> </representation>         </request>         <response>
> <representation mediaType="application/json" />         </response>
> </method>*
>
> Also the parameter name 'steam' is not accepted at all, as I get an 400 or
> 500 error. If I send the stream by the name 'file', as usual, I get 415.
>
> Unfortunately the catalina.out file doesn't report much more information.
>
>
>
>