Closed MattiasNilssonBeckhoff closed 4 years ago
@MattiasNilssonBeckhoff what version of Jira and Jira Service Desk are you using?
The patches proposed last night fixed the scrip for Jira Service Desk Cloud - but Server may be different.
Hi
Yes of course forgot to add that. Using Jira Service Desk för server, version 4.7.1. Using PostgreSQL 12.2.1 if that could affect?
Postgresql doesn't matter but Server vs Cloud will make a difference as the API's for Server and Cloud are subtly different. If you can hold of till tomorrow (~12 hours) I can test and publish a version which works for both server and cloud?
Sounds great!
@MattiasNilssonBeckhoff Work in progress branch here. Working for cloud but the following error is preventing me from testing on server.
{'errorMessage': 'Signup is not currently available', 'i18nErrorMessage': {'i18nKey': 'cv.signup.error.not.allowed', 'parameters': []}}
Any ideas how to enable signup? I feel like I need to setup an SMTP server for it to work.
@iokiwi Is the error from when adding customers? Could it be that you need to turn off that customers get a notification automatically when signed up? Project settings -> Customer notifications -> Do not sent account verification emails to enabled.
Figured it out :/
Cannot have spaces in CSV - user creation was failing - error message was misleading
2020-02-29 10:10:11,523+1300 http-nio-8080-exec-12 ERROR admin 610x1943x1 rplexz 172.18.0.1 /rest/servicedeskapi/customer [c.a.s.internal.user.ServiceDeskUserManagerImpl] Could not create user: john.smith@example.com
com.atlassian.crowd.exception.InvalidUserException: User name may not contain leading or trailing whitespace
at com.atlassian.crowd.manager.directory.DirectoryManagerGeneric.addUser(DirectoryManagerGeneric.java:308)
at com.atlassian.crowd.manager.directory.DirectoryManagerGeneric.addUser(DirectoryManagerGeneric.java:298)
at sun.reflect.GeneratedMethodAccessor764.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
at com.sun.proxy.$Proxy508.addUser(Unknown Source)
I'm not getting that error. Tried to remove spaces but still getting the same issue.
`2020-02-29 00:16:32,269 - INFO - Initializing session
2020-02-29 00:16:32,273 - DEBUG - Starting new HTTP connection (1): bas-jira01:8080 2020-02-29 00:16:32,361 - DEBUG - http://bas-jira01:8080 "GET /rest/auth/1/session HTTP/1.1" 200 None 2020-02-29 00:16:32,428 - DEBUG - http://bas-jira01:8080 "GET /rest/servicedeskapi/organization HTTP/1.1" 200 None 2020-02-29 00:16:32,542 - DEBUG - http://bas-jira01:8080 "POST /rest/servicedeskapi/customer HTTP/1.1" 500 None 2020-02-29 00:16:32,545 - DEBUG - "Unrecognized field \"displayName\" (Class com.atlassian.servicedesk.api.rest.dto.domain.user.CustomerCreateDTO), not marked as ignorable\n at [Source: org.apache.catalina.connector.CoyoteInputStream@331a5788; line: 1, column: 77] (through reference chain: com.atlassian.servicedesk.api.rest.dto.domain.user.CustomerCreateDTO[\"displayName\"])" 2020-02-29 00:16:32,553 - DEBUG - Resetting dropped connection: bas-jira01 2020-02-29 00:16:32,655 - DEBUG - http://bas-jira01:8080 "POST /rest/servicedeskapi/organization HTTP/1.1" 201 None 2020-02-29 00:16:32,658 - INFO - ACME was successfully created 2020-02-29 00:16:32,798 - DEBUG - http://bas-jira01:8080 "POST /rest/servicedeskapi/servicedesk/1/organization HTTP/1.1" 204 0 2020-02-29 00:16:32,799 - INFO - ACME was added to service desk 1 Failed to process row: ['ACME', ' john.snow@example.com', ' john.snow@example.com'] 2020-02-29 00:16:32,801 - ERROR - 'accountId' Traceback (most recent call last): File "C:\TEMP\bulk_customer_import.py", line 211, in main add_customer_to_organization(organization, customer) File "C:\TEMP\bulk_customer_import.py", line 103, in add_customer_to_organization fields = {"accountIds": [customer["accountId"]]} KeyError: 'accountId' 2020-02-29 00:16:32,950 - DEBUG - http://bas-jira01:8080 "POST /rest/servicedeskapi/customer HTTP/1.1" 500 None 2020-02-29 00:16:32,956 - DEBUG - "Unrecognized field \"displayName\" (Class com.atlassian.servicedesk.api.rest.dto.domain.user.CustomerCreateDTO), not marked as ignorable\n at [Source: org.apache.catalina.connector.CoyoteInputStream@331a5788; line: 1, column: 64] (through reference chain: com.atlassian.servicedesk.api.rest.dto.domain.user.CustomerCreateDTO[\"displayName\"])" 2020-02-29 00:16:32,960 - DEBUG - Resetting dropped connection: bas-jira01 2020-02-29 00:16:33,092 - DEBUG - http://bas-jira01:8080 "POST /rest/servicedeskapi/organization HTTP/1.1" 201 None 2020-02-29 00:16:33,096 - INFO - Mega Corp was successfully created 2020-02-29 00:16:33,286 - DEBUG - http://bas-jira01:8080 "POST /rest/servicedeskapi/servicedesk/1/organization HTTP/1.1" 204 0 2020-02-29 00:16:33,288 - INFO - Mega Corp was added to service desk 1 Failed to process row: ['Mega Corp', ' Jane.Doe2', ' jane.doe@example.com'] 2020-02-29 00:16:33,292 - ERROR - 'accountId' Traceback (most recent call last): File "C:\TEMP\bulk_customer_import.py", line 211, in main add_customer_to_organization(organization, customer) File "C:\TEMP\bulk_customer_import.py", line 103, in add_customer_to_organization fields = {"accountIds": [customer["accountId"]]} KeyError: 'accountId' 2020-02-29 00:16:33,443 - DEBUG - http://bas-jira01:8080 "POST /rest/servicedeskapi/customer HTTP/1.1" 500 None 2020-02-29 00:16:33,447 - DEBUG - "Unrecognized field \"displayName\" (Class com.atlassian.servicedesk.api.rest.dto.domain.user.CustomerCreateDTO), not marked as ignorable\n at [Source: org.apache.catalina.connector.CoyoteInputStream@331a5788; line: 1, column: 67] (through reference chain: com.atlassian.servicedesk.api.rest.dto.domain.user.CustomerCreateDTO[\"displayName\"])" 2020-02-29 00:16:33,453 - DEBUG - Resetting dropped connection: bas-jira01 2020-02-29 00:16:33,584 - DEBUG - http://bas-jira01:8080 "POST /rest/servicedeskapi/organization HTTP/1.1" 201 None 2020-02-29 00:16:33,586 - INFO - Super Company was successfully created 2020-02-29 00:16:33,775 - DEBUG - http://bas-jira01:8080 "POST /rest/servicedeskapi/servicedesk/1/organization HTTP/1.1" 204 0 2020-02-29 00:16:33,778 - INFO - Super Company was added to service desk 1 Failed to process row: ['Super Company', ' John.Smith', ' john.smith@example.com'] 2020-02-29 00:16:33,782 - ERROR - 'accountId' Traceback (most recent call last): File "C:\TEMP\bulk_customer_import.py", line 211, in main add_customer_to_organization(organization, customer) File "C:\TEMP\bulk_customer_import.py", line 103, in add_customer_to_organization fields = {"accountIds": [customer["accountId"]]} KeyError: 'accountId' An error occurred while processing the following rows. ['ACME', ' john.snow@example.com', ' john.snow@example.com'] ['Mega Corp', ' Jane.Doe2', ' jane.doe@example.com'] ['Super Company', ' John.Smith', ' john.smith@example.com']`
Hey @MattiasNilssonBeckhoff
RE removing the spaces - I didn't expect that would fix the script but It was blocking me from testing the script on server
I presume you are looking at my WIP branch. I'm still ironing out inconsistencies between cloud and server - I haven't merged the WIP branch yet because it's not quite finished.
Once the branch is stable and tested against both Cloud and Server I will merge it into master untill then it's still in active development / testing.
@MattiasNilssonBeckhoff PR here merged. https://github.com/iokiwi/jsd-bulk-customer-upload/pull/7
There's some known limitations with cloud for now but should work ok for you for server.
@iokiwi Tried the new script but not getting it to work. Get error directly when I run the script. I updated to latest Python 2.7.17. Which version are you running?
`C:\TEMP\bulk_customer_import>python -m bulk_customer_import -h
Traceback (most recent call last): File "C:\Python27\lib\runpy.py", line 163, in _run_module_as_main mod_name, _Error) File "C:\Python27\lib\runpy.py", line 119, in _get_module_details code = loader.get_code(mod_name) File "C:\Python27\lib\pkgutil.py", line 281, in get_code self.code = compile(source, self.filename, 'exec') File "C:\TEMP\bulk_customer_import\bulk_customer_import.py", line 69 LOG.info(f"Processing row: {row}") ^ SyntaxError: invalid syntax`
@MattiasNilssonBeckhoff its the 'f' string fstrings require python>=3.6.
I'm not going to support python 2.7
as it EOL January 1st 2020 but I can remove the fstring to support older versions of python 3.
Can you install python3? It will happily coexist with python 2.7. You may need to invoke it with python3 bulk_customer_import
I created an issue to remove fstrings from the code: https://github.com/iokiwi/jsd-bulk-customer-upload/issues/11
@MattiasNilssonBeckhoff fixed in issue #11
@iokiwi Worked perfect now, thanks! :)
Only Companies are added when running script. No customers are added. All three companies in example.csv are added.