What does your task look like? Also, the original report is against 2.4.2 which by now is almost 1.5 years old, and the uri module has since seen a lot of changes. What version do you run?
Dick On Wed, 3 Apr 2019 at 15:31, Fabio Martins <[email protected]> wrote: > I am facing exactly the same issue when trying to upload a jar file over a > Flink > REST endpoint > <https://ci.apache.org/projects/flink/flink-docs-stable/monitoring/rest_api.html#jars-upload> > . > > I tried both with curl and postman, it works flawlessly, but using Ansible > URI module, I am getting the error message: FAILED! => {"changed": false, > "content": "", "msg": "Status code was -1 and not [200]: Request failed: > <urlopen error [Errno 104] Connection reset by peer>", "redirected": false, > "status": -1, "url": "http://<MYHOSTNAME>:8081/jars/upload} > > Any idea, or should I continue using the shell module with curl (I don't > like it, but it's the only way it works for now). > > > On Monday, May 21, 2018 at 8:05:47 PM UTC+2, Apu Mondal wrote: >> >> Zip file not getting POST to the server with the uri module in Ansible. >> >> These are the codes I am trying to execute >> >> - name: Transfering the Proxies >> uri: >> headers: >> Authorization: '{{API_USER_PASS_BASE64_ENCRYPT}}' >> Content-Type: "application/octet-stream" >> url: >> >> https://api.enterprise.apigee.com/v1/organizations/{{API_ORG}}/apis?action=import&name={{proxy_name >> }}-{{API_ENVIRONMENT}} >> #body: "{{ lookup('file','{{ path >> >> }}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip') >> }}" --> doesn't work >> src: /{{ path >> }}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip >> body_format: raw >> status_code: 201, 200 >> method: POST >> register: version >> >> It gives the following error: >> "json": { >> "code": "messaging.config.beans.InvalidBundle", >> "contexts": [], >> "message": "Bundle is invalid. Empty bundle" >> }, >> >> Also it sets the "content_type": "application/json", at the top of the >> message like this: >> >> The full traceback is: >> File "/tmp/ansible_NyKoMf/ansible_module_uri.py", line 468, in main >> uresp['location'] = absolute_location(url, uresp['location']) >> >> fatal: [localhost]: FAILED! => { >> "changed": false, >> "connection": "Close", >> "content": "{\n "code" : "messaging.config.beans.InvalidBundle",\n >> "message" : "Bundle is invalid. Empty bundle",\n "contexts" : [ ]\n}", >> "content_length": "122", >> "content_type": "application/json", >> "date": "Mon, 14 May 2018 19:03:48 GMT", >> "invocation": { >> "module_args": { >> "attributes": null, >> "backup": null, >> "body": null, >> "body_format": "raw", >> "client_cert": null, >> "client_key": null, >> "content": null, >> "creates": null, >> "delimiter": null, >> "dest": null, >> "directory_mode": null, >> "follow": false, >> "follow_redirects": "safe", >> "force": false, >> "force_basic_auth": false, >> "group": null, >> "headers": { >> "Authorization": "Basic YXBvb3J2YS5tb25kYWxAaHVnaGVzLmNvbTphcG9vcnZhNw==", >> "Content-Type": "application/octet-stream" >> }, >> "http_agent": "ansible-httpget", >> "method": "POST", >> "mode": null, >> "owner": null, >> "regexp": null, >> "remote_src": null, >> "removes": null, >> "return_content": false, >> "selevel": null, >> "serole": null, >> "setype": null, >> "seuser": null, >> "src": >> "/var/tmp/APIGEE_COM_R001_B-001_P-001/apigee/proxies/FapProxy--hughes-dev-test-dev.zip", >> "status_code": [ >> "201", >> " 200" >> ], >> "timeout": 30, >> "unsafe_writes": null, >> "url": " >> https://api.enterprise.apigee.com/v1/organizations/hughes-dev/apis?action=import&name=FapProxy-sa-dev >> ", >> "url_password": null, >> "url_username": null, >> "use_proxy": true, >> "validate_certs": true >> } >> }, >> "json": { >> "code": "messaging.config.beans.InvalidBundle", >> "contexts": [], >> "message": "Bundle is invalid. Empty bundle" >> }, >> "msg": "Status code was not [201, 200]: HTTP Error 400: Bad Request", >> "redirected": false, >> "server": "Apigee LB", >> "status": 400, >> "url": " >> https://api.enterprise.apigee.com/v1/organizations/hughes-dev/apis?action=import&name=FapProxy-sa-dev >> " >> } >> >> >> 2) - name: Transfering the Proxies >> >> uri: >> headers: >> Authorization: '{{API_USER_PASS_BASE64_ENCRYPT}}' >> Content-Type: "application/zip" >> url: >> https://api.enterprise.apigee.com/v1/organizations/{{API_ORG}}/apis?action=import&name={{ >> proxy_name }}-{{API_ENVIRONMENT}} >> body: "{{ lookup('file','{{ path >> }}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip') >> }}" >> #src: '{{ path >> }}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip' >> #body_format: raw >> status_code: 201, 200 >> method: POST >> register: version >> >> >> Please check and provide information on how to properly POST a zip file. >> ISSUE TYPE >> >> - Bug Report >> - Feature Idea >> - Documentation Report >> >> COMPONENT NAME >> >> URI Module >> ANSIBLE VERSION >> >> ansible 2.4.2.0 >> >> CONFIGURATIONOS / ENVIRONMENT >> >> Red Hat Enterprise Linux Server 7.3 (Maipo) >> STEPS TO REPRODUCE >> >> - name: Transfering the Proxies >> uri: >> headers: >> Authorization: '{{API_USER_PASS_BASE64_ENCRYPT}}' >> Content-Type: "application/zip" >> url: >> https://api.enterprise.apigee.com/v1/organizations/{{API_ORG}}/apis?action=import&name={{ >> proxy_name }}-{{API_ENVIRONMENT}} >> body: "{{ lookup('file','{{ path >> }}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip') >> }}" >> #src: '{{ path >> }}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip' >> #body_format: raw >> status_code: 201, 200 >> method: POST >> register: version >> >> --- >> - name: Transfering the Proxies >> uri: >> headers: >> Authorization: '{{API_USER_PASS_BASE64_ENCRYPT}}' >> Content-Type: "multipart/form-data" >> url: >> https://api.enterprise.apigee.com/v1/organizations/{{API_ORG}}/apis?action=import&name={{ >> proxy_name }}-{{API_ENVIRONMENT}} >> #body: "{{ lookup('file','{{ path >> }}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip') >> }}" >> src: '{{ path >> }}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip' >> #body_format: raw >> status_code: 201, 200 >> method: POST >> register: version >> >> - name: Transfering the Proxies >> uri: >> headers: >> Authorization: '{{API_USER_PASS_BASE64_ENCRYPT}}' >> Content-Type: "application/octet-stream" >> url: >> https://api.enterprise.apigee.com/v1/organizations/{{API_ORG}}/apis?action=import&name={{ >> proxy_name }}-{{API_ENVIRONMENT}} >> #body: "{{ lookup('file','{{ path >> }}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip') >> }}" --> doesn't work >> src: /{{ path >> }}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip >> body_format: raw >> status_code: 201, 200 >> method: POST >> register: version >> >> EXPECTED RESULTS >> >> The zip file should be uploaded to the server. >> ACTUAL RESULTS >> >> Right now as uri module is not working I am using the curl command >> instead. >> But I want my code not to have dependency on the linux commands. Hence >> trying to use the uri module. >> >> - name: Transfering the Proxies >> command: 'curl -X POST --header "Authorization: Basic >> YXBvb3J2YS5tb25kYWxAaHVnaGVzLmNvbTphcG9vcnZhNw==" -F >> >> "file=@/{{path}}/{{bundle_name}}/apigee/proxies/{{proxy_name}}--hughes-dev-test-dev.zip" >> " >> >> https://api.enterprise.apigee.com/v1/organizations/{{API_ORG}}/apis?action=import&name={{proxy_name >> }}-{{API_ENVIRONMENT}}"' >> register: version >> >> Neither src nor body parameter is able to POST a zip or jar file to the >> server. >> > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/5dabaed3-840b-43af-b554-52428cfa7206%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/5dabaed3-840b-43af-b554-52428cfa7206%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Sent from a mobile device - please excuse the brevity, spelling and punctuation. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwNRCXer9kgXDWE29fYQ4cUPULEj-X617KSzz-_1B6HWtQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
