# Post Request import a Zip File, but observe an 500 error

**URL:** https://forum.robotframework.org/t/post-request-import-a-zip-file-but-observe-an-500-error/5539
**Category:** RequestsLibrary
**Created:** [4 April 2023 20:11 UTC](https://forum.robotframework.org/t/post-request-import-a-zip-file-but-observe-an-500-error/5539 "2023-04-04T20:11:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![astrowalker2013](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/astrowalker2013/32/1743_2.png) [@astrowalker2013](https://forum.robotframework.org/u/astrowalker2013)
#### Post date: [4 April 2023 20:11 UTC](https://forum.robotframework.org/t/post-request-import-a-zip-file-but-observe-an-500-error/5539/1 "2023-04-04T20:11:19Z")

</div>

Hello,

I have a question, I migrate my Test Automatique ( in Ready API) to Robotframework  
For a Test I have an endpoint api Rest who upload a zip file in a process.  
On Ready API when I used this I have this raw request

POST https://\*\*\*\*\*\*\*\*\*\*\*\*\*/xx/api/dossier//8b512815-f13a-48c9-b118-e78ee0ea7e07/import-process HTTP/1.1  
Accept-Encoding: gzip,deflate  
cookie: \*\*\*\*\*\*  
Content-Type: application/zip  
Content-Length: 2789  
Host: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*.com  
Connection: Keep-Alive  
User-Agent: Apache-HttpClient/4.5.2 (Java/17.0.5)

with in attach a zip file the import are OK

but my similar test I write with json send an error 500

```
 ${jsonprocess} ${EXECDIR}/ ******* /toto.zip
 ***Test Cases***
 Test1
      ${caseId} = create a folder ${jsoncasesfile}
      Import a process ${caseId}    
 ***Keywords**
Import a process
     [Documentation] This Function import a process in a folder           
     [Arguments] ${caseId}   
     ${header}= Create Dictionary Content-Type=application/zip Accept-Encoding=gzip,deflate     
     ${file}= Get File For Streaming Upload ${jsonprocess}
     ${files}= Create Dictionary randombyte ${file}     
     ${reponse}= POST On Session wwww /xx/api/dossier/${caseId}/import-process headers=${header} files=${files}   
     # Set Test Variable ${reponse} ${reponse.json()}
     # Log ${reponse}

```

How to write the import file, It the headers are not configure in best way.  
Thanks a lot for your Help.

Best

---

<div class="post-metadata">

### Author: ![astrowalker2013](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/astrowalker2013/32/1743_2.png) [@astrowalker2013](https://forum.robotframework.org/u/astrowalker2013)
#### Post date: [4 April 2023 21:32 UTC](https://forum.robotframework.org/t/post-request-import-a-zip-file-but-observe-an-500-error/5539/2 "2023-04-04T21:32:54Z")

</div>

I Complete my message with the error log in the report

```
21:58:58.391	INFO	POST Response : url=https:// **************** /rrr/rrrrr/058af787-22e4-4409-81f7-23089d5ff1f9/import-process 
 status=500, reason=Internal Server Error 
 headers={'Date': 'Tue, 04 Apr 2023 19:58:57 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Content-Language': 'en', 'Vary': 'Accept-Encoding', 'Request-Context': 'appId=', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains'} 
 body={"type":" *********************","title":"Internal server error","status":500,"instance":"/** / **i/c**** /058af787-22e4-4409-81f7-23089d5ff1f9/import-process"} 
 	
21:58:58.391	INFO	/usr/local/lib/python3.10/dist-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host ' **************'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(	
21:58:58.392	FAIL	HTTPError: 500 Server Error: Internal Server Error for url: https:
21:58:58.394	DEBUG	Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/RequestsLibrary/utils.py", line 154, in decorator
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/RequestsLibrary/RequestsOnSessionKeywords.py", line 62, in post_on_session
    self._check_status(expected_status, response, msg)
  File "/usr/local/lib/python3.10/dist-packages/RequestsLibrary/SessionKeywords.py", line 570, in _check_status
    resp.raise_for_status()
  File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https:// *********************** /import-process

```

I hiden all url

---

<div class="post-metadata">

### Author: ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)
#### Post date: [5 April 2023 09:37 UTC](https://forum.robotframework.org/t/post-request-import-a-zip-file-but-observe-an-500-error/5539/3 "2023-04-05T09:37:04Z")

</div>

Hi @astrowalker2013,

Given that you are uploading a single file, maybe try it like this:

```python
${jsonprocess} ${EXECDIR}/ ******* /toto.zip
 ***Test Cases***
 Test1
      ${caseId} = create a folder ${jsoncasesfile}
      Import a process ${caseId}    
 ***Keywords**
Import a process
     [Documentation] This Function import a process in a folder           
     [Arguments] ${caseId}   
     ${header}= Create Dictionary Content-Type=application/zip Accept-Encoding=gzip,deflate     
     ${file}= Get File For Streaming Upload ${jsonprocess}
     ${reponse}= POST On Session wwww /xx/api/dossier/${caseId}/import-process headers=${header} data=${file}   

```

If you have a working test case (you mentioned you are migrating your test case) what does the request headers/request body for the old test case look like? what’s different on request headers/request body when using robot framework?

Also if you can get access to the application server errors for this request that might give you a clue what the problem, i.e. it might say missing header xxx or body not correct format or something like that.

All we know for now is the server didn’t like what you sent it but no idea why, the error message `"Internal server error"` and the request path is not very helpful, but that might be by design?

Dave.

---

<div class="post-metadata">

### Author: ![astrowalker2013](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/astrowalker2013/32/1743_2.png) [@astrowalker2013](https://forum.robotframework.org/u/astrowalker2013)
#### Post date: [13 April 2023 18:38 UTC](https://forum.robotframework.org/t/post-request-import-a-zip-file-but-observe-an-500-error/5539/4 "2023-04-13T18:38:31Z")

</div>

ok corrected  
finaly it’s an issue of the api.

not an issue of request library
