Formatting Post json

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Formatting Post json

Post by AndyP » Tue Nov 21, 2023 6:06 pm

I'm playing around with the GitHub api and I am problems formatting the correct json string to send via tsnetPost.

I have this section of code from a working python script

Code: Select all

# Create a dictionary to store the data for your new repository
data = {
    "name": "my-new-repository",
    "description": "This is my new repository",
    "private": False
}

# Send a POST request to the API endpoint to create a new repository
response = requests.post(f"{api_base_url}/user/repos", json=data, headers={
    "Authorization": f"Bearer {personal_access_token}"
})
But I'm having problems formatting this correctly for the tsnetPost tPostData var as below

Code: Select all

put tsNetPost("connectionA",tUrl,tHeaders,tPostData,"postResponse") into tError
Normally I can get my head around this type of thing, but this one is stumping me.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

JereMiami
Posts: 119
Joined: Mon Nov 03, 2014 12:17 am

Re: Formatting Post json

Post by JereMiami » Tue Dec 26, 2023 1:14 am

Any luck with this?

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”