Skip to content

Allowed 'start_sync_job' to use an 'api' source #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2025

Conversation

CraigBryan
Copy link

The sync API doesn't need an integration id when using an 'api' source.

The sync API doesn't need an integration id when using an 'api' source.
@CraigBryan CraigBryan requested review from a team as code owners March 14, 2025 18:32
@CraigBryan
Copy link
Author

Example error

In [1]: from jupiterone import JupiterOneClient

In [2]: j1 = JupiterOneClient(account="<accountid>", token="<token>", url="https://graphql.us.jupiterone.io", sync_url="https://api.us.jupiterone.io")

In [3]: j1.start_sync_job(sync_mode="PATCH", source="api")
---------------------------------------------------------------------------
JupiterOneApiError                        Traceback (most recent call last)
Cell In[3], line 1
----> 1 j1.start_sync_job(sync_mode="PATCH", source="api")

File ~/.pyenv/versions/3.12.4/envs/j1_gh_push_pull/lib/python3.12/site-packages/jupiterone/client.py:549, in JupiterOneClient.start_sync_job(self, instance_id, sync_mode, source)
    541 endpoint = "/persister/synchronization/jobs"
    543 data = {
    544        "source": source,
    545        "integrationInstanceId": instance_id,
    546        "syncMode": sync_mode
    547        }
--> 549 response = self._execute_syncapi_request(endpoint=endpoint, payload=data)
    551 return response

File ~/.pyenv/versions/3.12.4/envs/j1_gh_push_pull/lib/python3.12/site-packages/jupiterone/client.py:313, in JupiterOneClient._execute_syncapi_request(self, endpoint, payload)
    311     data = json.loads(content)
    312     content = data.get("error", data.get("errors", content))
--> 313 raise JupiterOneApiError("{}:{}".format(response.status_code, content))

JupiterOneApiError: 400:{'message': 'Expected { source: "api"; scope?: string; syncMode?: "DIFF" | "CREATE_OR_UPDATE" | "PATCH"; deletionMode?: "SOFT_DELETE" | "HARD_DELETE"; } | { source: "integration-managed" | "integration-external"; integrationInstanceId: string; integrationJobId?: string; syncMode?: "DIFF" | "CREATE_OR_UPDATE" | "PATCH"; deletionMode?: "SOFT_DELETE" | "HARD_DELETE"; }, but was object', 'code': 'MALFORMED_PAYLOAD', 'errorType': 'USER_ERROR', 'statusCode': 400, 'correlationId': '468f13c1-f403-4a27-9623-cd68c65cdb90'}

@SeaBlooms SeaBlooms merged commit 43ca985 into JupiterOne:main Mar 21, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants