bugfix: fix api request custom component (#2470)
* bugfix: fix api request custom component * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
fb21fdda5e
commit
8980e75723
10 changed files with 22 additions and 14 deletions
|
|
@ -112,10 +112,18 @@ class APIRequestComponent(Component):
|
|||
if method not in ["GET", "POST", "PATCH", "PUT", "DELETE"]:
|
||||
raise ValueError(f"Unsupported method: {method}")
|
||||
|
||||
if isinstance(body, str) and body:
|
||||
try:
|
||||
body = json.loads(body)
|
||||
except Exception as e:
|
||||
logger.error(f"Error decoding JSON data: {e}")
|
||||
body = None
|
||||
raise ValueError(f"Error decoding JSON data: {e}")
|
||||
|
||||
data = body if body else None
|
||||
payload = json.dumps(data) if data else None
|
||||
|
||||
try:
|
||||
response = await client.request(method, url, headers=headers, content=payload, timeout=timeout)
|
||||
response = await client.request(method, url, headers=headers, json=data, timeout=timeout)
|
||||
try:
|
||||
result = response.json()
|
||||
except Exception:
|
||||
|
|
|
|||
|
|
@ -280,7 +280,12 @@ class Vertex:
|
|||
# we don't know the key of the dict but we need to set the value
|
||||
# to the vertex that is the source of the edge
|
||||
param_dict = template_dict[param_key]["value"]
|
||||
params[param_key] = {key: self.graph.get_vertex(edge.source_id) for key in param_dict.keys()}
|
||||
if param_dict:
|
||||
params[param_key] = {
|
||||
key: self.graph.get_vertex(edge.source_id) for key in param_dict.keys()
|
||||
}
|
||||
else:
|
||||
params[param_key] = self.graph.get_vertex(edge.source_id)
|
||||
else:
|
||||
params[param_key] = self.graph.get_vertex(edge.source_id)
|
||||
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ class NestedDictInput(BaseInputMixin, ListableInputMixin, MetadataTraceMixin, In
|
|||
"""
|
||||
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.NESTED_DICT
|
||||
value: Optional[dict] = {}
|
||||
value: Optional[dict | Data] = {}
|
||||
|
||||
|
||||
class DictInput(BaseInputMixin, ListableInputMixin, InputTraceMixin):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue