Package - Preserve JSON from Script to HTTP Post

More
2 years 4 weeks ago - 2 years 4 weeks ago #24077 by prashant
HI,
I have a properly defined JSON in a variable in SCRIPT. When I pass this to HTTP Post as a variable , json structure is lost , it's passed as a string (as it's supposed to) , but is there a way to preserve this JSON structure?

 

Code:
import etltools import json def main():     try:         # Retrieve the JSON value as a string         xjson = etltools.GetVariable('<json_variable>')         # Retrieve the gdrive value as a string         gdrive_value = etltools.GetVariable('gdrive_value')         # Convert JSON string to dictionary to ensure it's valid JSON         xjson_value = json.loads(xjson)         # Add the gdrive link to the JSON dictionary         gdrive_link = {"{{g_link}}": f"https://drive.google.com/file/d/{gdrive_value}/view?usp=drive_link"}         xjson_value.update(gdrive_link)         # Convert the updated dictionary back to a JSON string         updated_json_value_str = json.dumps(xjson_value)         # Set the updated JSON string as a variable in ETL tools         etltools.SetVariable('updated_json', updated_json_value_str)         # Indicate success         Result.Value = 1     except Exception as e:         # Log the error message in ETL tools         # etltools.SetVariable('error_message', str(e))         # Indicate failure         Result.Value = 0 if __name__ == "__main__":     main()


 
Last edit: 2 years 4 weeks ago by prashant.
The following user(s) said Thank You: Peter.Jonson

Please Log in or Create an account to join the conversation.

More
2 years 4 weeks ago #24078 by Peter.Jonson
Please post screenshots of HTTP Post properties

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

More
2 years 4 weeks ago #24079 by prashant

Please Log in or Create an account to join the conversation.

More
2 years 3 weeks ago #24080 by Peter.Jonson
I assume updated_json is a variable?

Can you post header tab a well 

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

More
2 years 3 weeks ago #24081 by prashant
# Convert the updated dictionary back to a JSON string
        updated_json_value_str = json.dumps(xjson_value)
        # Set the updated JSON string as a variable in ETL tools
        #etltools.SetVariable('updated_json', updated_json_value_str)

Please Log in or Create an account to join the conversation.

More
2 years 3 weeks ago #24082 by Peter.Jonson
This is not header tab

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save