Update Sharepoint.yaml
This commit is contained in:
@@ -133,12 +133,11 @@
|
|||||||
msg:
|
msg:
|
||||||
names: "{{ (cols_probe.json.value | default([])) | map(attribute='name') | list }}"
|
names: "{{ (cols_probe.json.value | default([])) | map(attribute='name') | list }}"
|
||||||
|
|
||||||
# --- Create list item ---
|
# --- Create list item (no block/rescue; use ignore_errors + diagnostics) ---
|
||||||
- name: Create SharePoint list item (Graph)
|
- name: Create SharePoint list item (Graph)
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: true
|
run_once: true
|
||||||
block:
|
uri:
|
||||||
- uri:
|
|
||||||
url: "https://graph.microsoft.com/v1.0/sites/{{ site_id }}/lists/{{ list_id }}/items"
|
url: "https://graph.microsoft.com/v1.0/sites/{{ site_id }}/lists/{{ list_id }}/items"
|
||||||
method: POST
|
method: POST
|
||||||
headers:
|
headers:
|
||||||
@@ -157,9 +156,33 @@
|
|||||||
{{ summary_text }}
|
{{ summary_text }}
|
||||||
Recap: {{ hostvars['localhost'].recap_line }}
|
Recap: {{ hostvars['localhost'].recap_line }}
|
||||||
register: sp_create
|
register: sp_create
|
||||||
|
ignore_errors: true
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
||||||
rescue:
|
- name: Show sanitized Graph error (if any)
|
||||||
- name: Sanitize and print the error
|
|
||||||
run_once: true
|
run_once: true
|
||||||
|
when: sp_create is failed
|
||||||
|
vars:
|
||||||
|
_json: "{{ sp_create.json | default({}) }}"
|
||||||
|
debug:
|
||||||
|
msg:
|
||||||
|
status: "{{ sp_create.status | default('n/a') }}"
|
||||||
|
graph_error: >-
|
||||||
|
{{ _json.error.message
|
||||||
|
| default(_json.message
|
||||||
|
| default(sp_create.msg | default('Unknown error'))) }}
|
||||||
|
hint: >
|
||||||
|
400: column internal names; 401: scope/audience; 403: permissions;
|
||||||
|
404: siteId/listId.
|
||||||
|
|
||||||
|
- name: Fail if SharePoint item was not created
|
||||||
|
run_once: true
|
||||||
|
when: sp_create is failed
|
||||||
|
fail:
|
||||||
|
msg: "Failed to create SharePoint item (see previous message)."
|
||||||
|
|
||||||
|
- name: Show created list item id
|
||||||
|
run_once: true
|
||||||
|
when: sp_create is succeeded
|
||||||
|
debug:
|
||||||
|
var: sp_create.json.id
|
||||||
Reference in New Issue
Block a user