Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Help with weird Siemens Polarion endpoints#1196

Unanswered
bigblondewolfpersonal asked this question inQ&A
Discussion options

I'm further struggling with the Siemens Polarion REST API, which seems to be not perfectly specified and need your expert opinion.

Here's the API specification to play around, the test drive server is open, although Polarion itself is not. You may need to register and generate an API key to run queries:https://testdrive.polarion.com/polarion/rest/v1

What puzzles me is theGET /projects/{projectId}/workitems endpoint'sfield item. It is defined as a SparseFields object, which should look like this:

{  "categories": "@all",  "documents": "@all",  ...}

When I click "Try it out", this translates tohttps://testdrive.polarion.com/polarion/rest/v1/projects/testproj/workitems?fields[categories]=@all&fields[documents]=@all. This seems strange query format, is this universally accepted?

The generated python client expects a SparseFields object that gets sent to the httpx request with to_dict() and each field is treated as an individual query parameter. When I callwil : workitems_list_get_response.WorkitemsListGetResponse = get_work_items.sync_detailed(client=client, project_id="testproj", fields=SparseFields(categories="@all", documents="@all")) this URL is requested:https://testdrive.polarion.com/polarion/rest/v1/projects/testproj/workitems?categories=@all&documents=@all')

I resolved it by patching get_work_items._get_kwargs() like this:

json_fields: Union[Unset, dict[str, Any]] = UNSET    if not isinstance(fields, Unset):        json_fields = fields.to_dict()    if not isinstance(json_fields, Unset):        f = {}        for k, v in json_fields.items():            f[f"fields[{k}]"]=v        params.update(f)

Is there anything better I colud do?
Am I misunderstading how to use the endpoint?
Or is it really weirdly coded?

Thanks a lot!

You must be logged in to vote

Replies: 1 comment

Comment options

I actually patched the SparseFields model, as it is used in all GET tequests, but I'm still wondering if that's right.

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
1 participant
@bigblondewolfpersonal

[8]ページ先頭

©2009-2025 Movatter.jp