Forum Migration Notice
Update (2026-01-21): The user forums are now in read-only mode pending the data migration.
Update (2026-01-12): The user forums will be put into read-only mode on the 21st of January, 00:00 CET, to prepare for the data migration.
We're transitioning to a more modern community platform by beginning of next year. Learn about the upcoming changes and what to expect.
Update (2026-01-12): The user forums will be put into read-only mode on the 21st of January, 00:00 CET, to prepare for the data migration.
We're transitioning to a more modern community platform by beginning of next year. Learn about the upcoming changes and what to expect.
POST and PUT Syntax in Python
Piotrekk
✭
Hello Everyone,
I'm currently working on a project combining generating RAPID code with ChatGPT and sending it via Robot Web Services to GoFa.
I'm working in Python.
So far I've been able to establish connection and use GET method correctly.
However I receive Forbidden Request errors(403) while trying to use POST.
Also I'm looking for PUT Syntax(especially for Uploading a file) since "Execute" button doesn't seem to work correctly on DeveloperCenter site:
https://developercenter.robotstudio.com/api/RWS
Here's my code so far.
Could You please let me know what's wrong with it?
I'm currently working on a project combining generating RAPID code with ChatGPT and sending it via Robot Web Services to GoFa.
I'm working in Python.
So far I've been able to establish connection and use GET method correctly.
However I receive Forbidden Request errors(403) while trying to use POST.
Also I'm looking for PUT Syntax(especially for Uploading a file) since "Execute" button doesn't seem to work correctly on DeveloperCenter site:
https://developercenter.robotstudio.com/api/RWS
Here's my code so far.
Could You please let me know what's wrong with it?
from aiohttp.hdrs import CONTENT_TYPE
from requests.auth import HTTPBasicAuth
import logging
import requests
import json
# Konfiguracja autoryzacji
basic_auth = HTTPBasicAuth("Default User", "robotics")
# Ustawienie formatowania logów
FORMAT = '%(asctime)-15s%(message)s'
logging.basicConfig(format=FORMAT, level=logging.DEBUG)
logger = logging.getLogger('RWS')
# Nagłówki
get_headers = {'Accept': 'application/hal+json;v=2.0'}
post_headers = {'Accept': 'application/json',
'Content-Type':'application/x-www-form-urlencoded;v=2.0'}
# Funkcja do wykonywania zapytań HTTP
def send_request(conn, method, uri, headers=None, data=None, proto='https://', host='192.168.125.1:443'):
url = f"{proto}{host}{uri}"
try:
# Wykonanie żądania HTTP
resp = conn.request(method, url, auth=basic_auth, headers=headers, data=data, verify=False)
logger.info(f"{method} {url} - Status Code: {resp.status_code}")
if resp.status_code == 200:
logger.info(f"Response: {resp.json()}")
else:
logger.error(f"Error: Failed to access URI '{uri}', Status Code: {resp.status_code}")
return resp
except Exception as e:
# Logowanie błędów
logger.error(f"Error: {e}")
return None
if __name__ == '__main__':
# Utworzenie sesji
conn = requests.Session()
conn.cookies.clear() # Upewnienie się, że ciasteczka są czyste przed logowaniem
# Wykonanie żądania GET
send_request(conn, 'GET', '/ctrl/clock', headers=get_headers)
# Wykonanie żądania POST
send_request(conn, 'POST', '/rw/rapid/execution/resetpp?mastership=explicit', headers=post_headers)
# Zamknięcie sesji
conn.close()
Tagged:
0
Categories
- All Categories
- 5.7K RobotStudio
- 402 UpFeed
- 21 Tutorials
- 16 RobotApps
- 307 PowerPacs
- 407 RobotStudio S4
- 1.8K Developer Tools
- 251 ScreenMaker
- 2.9K Robot Controller
- 368 IRC5
- 92 OmniCore
- 8 RCS (Realistic Controller Simulation)
- 859 RAPID Programming
- 43 AppStudio
- 4 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 111 Collaborative Robots
- 5 Job listings