Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for sending raw request bodies #13

Open
peritus opened this issue Feb 12, 2013 · 4 comments
Open

Support for sending raw request bodies #13

peritus opened this issue Feb 12, 2013 · 4 comments

Comments

@peritus
Copy link
Owner

peritus commented Feb 12, 2013

There is no way to send a raw request body (e.g. a binary file), everything is UTF-8 encoded.

Webtest supports this somehow, so should this library.

@peritus
Copy link
Owner Author

peritus commented Sep 10, 2013

Note to self: Perhaps Get Binary File [http://robotframework.googlecode.com/hg/doc/libraries/OperatingSystem.html?r=2.8.1#Get_Binary_File] in combination with Set Request Body works.

@peritus peritus removed their assignment Jun 11, 2014
@pm-sachin-nikam
Copy link

Hi @peritus ,

I tried to use "Set Request Body" and "Get Binary File" but getting following error:

20150414 18:05:42.999 : DEBUG : Response headers:
20150414 18:05:42.999 : DEBUG : date: Tue, 14 Apr 2015 10:00:42 GMT
20150414 18:05:43.000 : DEBUG : content-length: 0
20150414 18:05:43.000 : DEBUG : server: Apache-Coyote/1.1
20150414 18:05:43.000 : DEBUG : No response body received
20150414 18:05:43.001 : FAIL : Request should have succeeded, but was "415 Unsupported Media Type".
20150414 18:05:43.002 : DEBUG :
Traceback (most recent call last):
File "c:\Python27\lib\site-packages\HttpLibrary__init__.py", line 248, in POST
self.context.request_headers, **kwargs)
File "c:\Python27\lib\site-packages\HttpLibrary__init__.py", line 102, in post_process_request
self.response.status

@peritus
Copy link
Owner Author

peritus commented Apr 14, 2015

20150414 18:05:43.001 : FAIL : Request should have succeeded, but was "415 Unsupported Media Type".

If there is no response body, you can't retrieve it.

@pm-sachin-nikam
Copy link

Hi @peritus ,

Thanks for your reply.

When I execute api using rest client to upload file. It works fine.

I was trying to automate it, but it is failing with error 415.

Below is the complete log:

Starting test: Automation.Test Suite.file upload
20150415 09:01:01.876 : TRACE : Arguments: [ u'192.168.1.1:8080' | u'http' ]
20150415 09:01:01.876 : INFO : Host for next HTTP request set to '192.168.1.1:8080'
20150415 09:01:01.876 : INFO : Scheme for next HTTP request set to 'http'
20150415 09:01:01.876 : TRACE : Return: None
20150415 09:01:01.876 : TRACE : Arguments: [ u'g:\new.csv' | encoding=u'UTF-8' ]
20150415 09:01:01.876 : INFO : Getting file 'g:\new.csv'
20150415 09:01:01.876 : TRACE : Return: "ID","Domain","URL"\n"24441","http://www.mycompany.com","http://www.mycompany.com"'
20150415 09:01:01.876 : INFO :
${Request_Body} = "ID","Domain","URL"
"24441","http://www.mycompany.com","http://www.mycompany.com"
20150415 09:01:01.886 : TRACE : Arguments: [ u'Content-Type' | u'application/vnd.ms-excel' ]
20150415 09:01:01.886 : INFO : Set request header "Content-Type" to "application/vnd.ms-excel"
20150415 09:01:01.886 : TRACE : Return: None
20150415 09:01:01.886 : TRACE : Arguments: [ u'\ufeff"ID","Domain","URL"\n"24441","http://www.mycompany.com","http://www.mycompany.com"' ]
20150415 09:01:01.886 : INFO :
Request body set to ""ID","Domain","URL"
"24441","http://www.mycompany.com","http://www.mycompany.com"".
20150415 09:01:01.886 : TRACE : Return: None
20150415 09:01:01.886 : TRACE : Arguments: [ u'/fileUpload' ]
20150415 09:01:01.886 : DEBUG : Performing POST request on http://192.168.1.1:8080/fileUpload
20150415 09:01:01.886 : DEBUG : Request headers:
20150415 09:01:01.886 : DEBUG : Host: 192.168.1.1:8080
20150415 09:01:01.886 : DEBUG : Content-Type: application/vnd.ms-excel
20150415 09:01:01.886 : DEBUG : Request body:
20150415 09:01:01.886 : DEBUG :
"ID","Domain","URL"
"24441","http://www.mycompany.com","http://www.mycompany.com"
20150415 09:01:01.906 : DEBUG : Response status line: 415 Unsupported Media Type
20150415 09:01:01.906 : DEBUG : Response headers:
20150415 09:01:01.906 : DEBUG : date: Wed, 15 Apr 2015 00:56:01 GMT
20150415 09:01:01.906 : DEBUG : content-length: 0
20150415 09:01:01.906 : DEBUG : server: Apache-Coyote/1.1
20150415 09:01:01.906 : DEBUG : No response body received
20150415 09:01:01.906 : FAIL : Request should have succeeded, but was "415 Unsupported Media Type".
20150415 09:01:01.916 : DEBUG :
Traceback (most recent call last):
File "c:\Python27\lib\site-packages\HttpLibrary__init__.py", line 248, in POST
self.context.request_headers, **kwargs)
File "c:\Python27\lib\site-packages\HttpLibrary__init__.py", line 102, in post_process_request
self.response.status
Ending test: Automation.Test Suite.file upload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants