Passing data from ansible to service now table

Hi Team,

I am sending data from ansible to service now using uri, data is passing to snow table but job status is not showing successful.
I am getting “The read operation timed out” error ,Please suggest me how this can be resolved

  • name: Passing Data to Snow
    uri:
    url: “https://test.service-now.com/api/eplc/table_update_integration/create
    method: POST
    Headers: “application/json”
    body: ‘{“List”:{{EPG_all}}, “Region”:"NA " }’
    body_format: json
    user: “{{ snow_username }}”
    password: “{{ snow_password }}”
    force_basic_auth: yes
    status_code: 200
    timeout: 10

Hi Team,

I am sending data from ansible to service now using uri, data is passing to snow table but job status is not showing
successful.
I am getting "The read operation timed out" error ,Please suggest me how this can be resolved
- name: Passing Data to Snow
uri:
url: "https://test.service-now.com/api/eplc/table_update_integration/create"
method: POST
Headers: "application/json"
body: '{"List":{{EPG_all}}, "Region":"NA " }'
body_format: json
user: "{{ snow_username }}"
password: "{{ snow_password }}"
force_basic_auth: yes
status_code: 200
timeout: 10

It certainly doesn't help that you reduce the timeout to 10 seconds. Also please post complete error message (without
the credentials).

Regards
        Racke

Hi Racke,

I have already increase the timeout but still getting the same error.
“Status code was -1 and not [200]: ‘The read operation timed out’”

Please find the complete tasks out put-

{
“status”: -1,
“_ansible_no_log”: false,
“url”: “https://test.service-now.com/api/eplc/table_update_integration/create”,
“changed”: false,
“elapsed”: 10,
“content”: “”,
“invocation”: {
“module_args”: {
“directory_mode”: null,
“force”: false,
“remote_src”: null,
“status_code”: [
“200”
],
“follow”: false,
“owner”: null,
“body_format”: “json”,
“client_key”: null,
“group”: null,
“use_proxy”: true,
“unix_socket”: null,
“unsafe_writes”: null,
“serole”: null,
“content”: null,
“setype”: null,
“follow_redirects”: “safe”,
“return_content”: false,
“method”: “POST”,
“body”: {
“Region”: “NA - Prod”,
“List”: [
data
},
“url_username”: “",
“src”: null,
“dest”: null,
“selevel”: null,
“force_basic_auth”: true,
“removes”: null,
“http_agent”: “ansible-httpget”,
“user”: “”,
“regexp”: null,
“password”: "
",
“url_password”: "
**”,
“url”: “https://test.service-now.com/api/eplc/table_update_integration/create”,
“backup”: null,
“seuser”: null,
“client_cert”: null,
“creates”: null,
“headers”: {
“Content-Type”: “application/json”
},
“delimiter”: null,
“mode”: null,
“timeout”: 100,
“attributes”: null,
“validate_certs”: true
}
},
“redirected”: false,
“msg”: “Status code was -1 and not [200]: ‘The read operation timed out’”
}

Please find the complete tasks out put-
{
"status": -1,
"_ansible_no_log": false,
"url": "https://test.service-now.com/api/eplc/table_update_integration/create",
"changed": false,
"elapsed": 10,
"content": "",
"invocation": {
"module_args": {
"directory_mode": null,
"force": false,
"remote_src": null,
"status_code": [
"200"
],
"follow": false,
"owner": null,
"body_format": "json",
"client_key": null,
"group": null,
"use_proxy": true,
"unix_socket": null,
"unsafe_writes": null,
"serole": null,
"content": null,
"setype": null,
"follow_redirects": "safe",
"return_content": false,
"method": "POST",
"body": {
"Region": "NA - Prod",
"List": [
data
},
"url_username": "****",
"src": null,
"dest": null,
"selevel": null,
"force_basic_auth": true,
"removes": null,
"http_agent": "ansible-httpget",
"user": "",
"regexp": null,
"password": "***",
"url_password": "***",
"url": "https://test.service-now.com/api/eplc/table_update_integration/create",
"backup": null,
"seuser": null,
"client_cert": null,
"creates": null,
"headers": {
"Content-Type": "application/json"
},
"delimiter": null,
"mode": null,
"timeout": 100,
"attributes": null,
"validate_certs": true
}
},
"redirected": false,
"msg": "Status code was -1 and not [200]: 'The read operation timed out'"
}

I would increase the timeout to a ridiculous value like 20 minutes and test if it:

* succeeds
* stops before the timeout exceeded
* stops after the timeout exceeded

Regards
         Racke

Hi Rack,

As you suggested I have increased the timeout to 20 min but still getting the same error and task stops before the timeout value.

Hi Rack,

As you suggested I have increased the timeout to 20 min but still getting the same error and task stops before the
timeout value.

So it is most likely that the API causes your problems. Please investigate at that end.

Regards
         Racke

thanks Rack one more thing I have observed sometimes i am getting belwo connection failure and some time Read operation timeout error.
Status code was -1 and not [200]: Connection failure: connection was closed before a valid response was received: ‘’"

could you please suggest what the possible reason of this two errors.? and in my ansible script has no issue.

thanks Rack one more thing I have observed sometimes i am getting belwo connection failure and some time Read
operation timeout error.
Status code was -1 and not [200]: Connection failure: connection was closed before a valid response was received: ''"

could you please suggest what the possible reason of this two errors.? and in my ansible script has no issue.

For the third and last time: most likely reason is the *API itself*.

Regards
         Racke

Thanks Racke for you help.

Is the Body Correct ? and that you aren’t missing any JSON values?