Skip to content

Commit

Permalink
Merge pull request #217 from nrjadkry/form_fields
Browse files Browse the repository at this point in the history
created an api which returns the form fields for the xform in central
  • Loading branch information
robsavoye authored Jan 1, 2024
2 parents 020125f + f3dd122 commit 568e4d0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions osm_fieldwork/OdkCentral.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,33 @@ def publishForm(
log.info(f"Published {xform} on Central.")
return result.status_code


def form_fields(self,
projectId:int,
xform:str):

"""
Retrieves the form fields for a xform from odk central.
Args:
projectId (int): The ID of the project on ODK Central
xform (str): The XForm to get the details of from ODK Central
Returns:
dict: A json object containing the form fields.
"""

if xform.find("_") > 0:
xid = xform.split('_')[2]
else:
xid = xform

url = f"{self.base}projects/{projectId}/forms/{xid}/fields?odata=true"
result=self.session.get(url, auth=self.auth)
return result.json()


def dump(self):
"""Dump internal data structures, for debugging purposes only."""
# super().dump()
Expand Down

0 comments on commit 568e4d0

Please sign in to comment.