Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Version 1.2.7](https://github.com/dataiku/dss-plugin-api-connect/releases/tag/v1.2.7) - Feature - 2026-02-18

- Detecting dialect for better csv decoding
- Fixing duplication of last line in csv APIs using the recipe

## [Version 1.2.6](https://github.com/dataiku/dss-plugin-api-connect/releases/tag/v1.2.6) - Feature - 2025-09-24

Expand Down
2 changes: 1 addition & 1 deletion python-lib/dku_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class DKUConstants(object):
API_RESPONSE_KEY = "api_response"
FORBIDDEN_KEYS = ["token", "password", "api_key_value", "secure_token"]
FORM_DATA_BODY_FORMAT = "FORM_DATA"
PLUGIN_VERSION = "1.2.7-beta.1"
PLUGIN_VERSION = "1.2.7-beta.2"
RAW_BODY_FORMAT = "RAW"
REPONSE_ERROR_KEY = "dku_error"
23 changes: 20 additions & 3 deletions python-lib/rest_api_recipe_session.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataikuapi.utils import DataikuException
from rest_api_client import RestAPIClient
from safe_logger import SafeLogger
from dku_utils import parse_keys_for_json, get_value_from_path, decode_csv_data, de_NaN
from dku_utils import parse_keys_for_json, get_value_from_path, decode_csv_data, de_NaN, decode_bytes
from dku_constants import DKUConstants
import copy
import json
Expand Down Expand Up @@ -108,6 +108,7 @@ def retrieve_next_page(self, is_raw_output):
# Todo: check api_response key is free and add something overwise
base_row = copy.deepcopy(metadata)
if is_raw_output:
assert_json(json_response)
if is_error_message(json_response):
base_row.update(parse_keys_for_json(json_response))
else:
Expand All @@ -125,8 +126,18 @@ def retrieve_next_page(self, is_raw_output):
base_row.update(self.initial_parameter_columns)
page_rows.append(base_row)
else:
json_response = decode_csv_data(json_response)
for row in json_response:
decoded_csv_data = decode_csv_data(json_response)
is_api_returning_dict = False
if not decoded_csv_data and json_response:
logger.warning("Data is not in CSV format. Dumping it in text mode.")
decoded_csv_data = [
{
DKUConstants.API_RESPONSE_KEY: "{}".format(
decode_bytes(json_response)
)
}
]
for row in decoded_csv_data:
base_row = copy.deepcopy(metadata)
base_row.update(parse_keys_for_json(row))
base_row.update(self.initial_parameter_columns)
Expand Down Expand Up @@ -181,3 +192,9 @@ def is_error_message(jsons_response):
return True
else:
return False


def assert_json(variable_to_check):
if isinstance(variable_to_check, dict) or isinstance(variable_to_check, list):
return
raise Exception("Returned data is not JSON format. Try again with 'Raw JSON output' un-checked.")