Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

REST-API get-request - Error: truncated response

REST-API get-request - Error: truncated response

DanielToGo
New Poster

Hello community,

I'm working on a python project which needs the configuration data of a solution so I tried receiving it via get-request in the REST-API on my virtual core. The requests seems to work and it responds with a 200 code however I get an error message saying the "message is truncated" instead of the content. Getting a bearer Token via POST-Request works though and I also tried to request it with the same data via the ctrlX OS and Postman. Both work fine and I get the full JSON-Data.
Does anyone know what the problem is and how I can fix it?

Thanks in advance! Heres the code and its output:

 

 

head = {"accept": "application/json", 'Authorization': 'Bearer {}'.format(token)}
url = 'https://10.0.2.2:8443/solutions/api/v1/solutions/DefaultSolution/configurations'

with requests.get(url, headers=head, verify=False) as response:
    data = json.loads(response.text)
    print(response.json())
    print(data)
    print(response.status_code)
    print(response.text)
2024-10-18T08:40:07Z sdk-py-webserver[24635]: - (error decoding original message: message key "MESSAGE" truncated)
2024-10-18T08:40:07Z sdk-py-webserver[24635]: - (error decoding original message: message key "MESSAGE" truncated)
2024-10-18T08:40:07Z sdk-py-webserver[24635]: 200
2024-10-18T08:40:07Z sdk-py-webserver[24635]: - (error decoding original message: message key "MESSAGE" truncated)

 

 

 

2 REPLIES 2

Sgilk
Frequent Contributor

Hi @DanielToGo ,

I tried to reproduce your issue and was unable to. I recieve the entire response object.

Code

 

 

    url = 'https://10.0.2.2:8443/identity-manager/api/v1/auth/token'
    head = {"Content-Type": "application/json"}
    creds = {"name":"boschrexroth","password":"boschrexroth"}
    with requests.post(url, headers=head,verify=False,json=creds) as response:
        data = json.loads(response.text)
        token = data['access_token']
        print(data)
        print(response.status_code)
        print(response.text)

    head = {"accept": "application/json", 'Authorization': 'Bearer {}'.format(token)}
    url = 'https://10.0.2.2:8443/solutions/api/v1/solutions/DefaultSolution/configurations'

    with requests.get(url, headers=head, verify=False) as response:
        data = json.loads(response.text)
        print(response.json())
        print(data)
        print(response.status_code)
        print(response.text)

 

 

Response

 

 

[{"name":"appdata","deploy":{},"active":true,"modtime":"2024-09-23T18:21:44.489462741Z","device":"VirtualControl-2-6-8","user":"boschrexroth","apps":[{"name":"bare","version":"1.0"},{"name":"core20","version":"20230126"},{"name":"core22","version":"20230801"},{"name":"ctrlx-influxdb","title":"InfluxDB","version":"2.6.0+2.7.5","appDirectories":[{"name":"influxdb","description":"InfluxDB configuration","icon":"bosch-ic-core-data","copyOnLoad":true,"writeProtected":false}]},{"name":"ctrlx-jupyter","title":"ctrlX Jupyter","version":"1.20.0"},{"name":"ctrlx-mosquitto","title":"Mosquitto MQTT Broker","version":"2.0.19","appDirectories":[{"name":"mosquitto","description":"Mosquitto","icon":"bosch-ic-cloud-share","copyOnLoad":true}]},{"name":"ctrlx-node-red","title":"Node-RED","version":"2.6.5+3.1.11-ctrlx","appDirectories":[{"name":"node-RED","description":"Node-RED configuration (userDir)","icon":"bosch-ic-directory","copyOnLoad":true,"writeProtected":false}]},{"name":"ctrlx-smarthmi-webiq-runtime","title":"WebIQ Server App (Runtime App)","version":"2.15.7"},{"name":"ctrlx-telegraf","title":"Telegraf","version":"2.6.1+1.29.4","appDirectories":[{"name":"telegraf","description":"Telegraf configuration","icon":"bosch-ic-chart-line-checkmark","copyOnLoad":true,"writeProtected":false}]},{"name":"rexroth-arch02-engineering","title":"Hardware Support","version":"2.6.2"},{"name":"rexroth-arch02-virtual-kernel","title":"Virtual Kernel","version":"6.1.33-rt11-ctrlx-28.3"},{"name":"rexroth-automationcore","title":"Automation Core","version":"2.6.2","appDirectories":[{"name":"datalayer","description":"Data Layer","icon":"ctrlx-ic-data-layer","copyOnLoad":true},{"name":"scheduler","description":"Scheduler: Tasks, callables and timing settings","icon":"bosch-ic-cycletime-eighth","copyOnLoad":true},{"name":"script","description":"Scripts configurations","icon":"bosch-ic-document-code-stack","copyOnLoad":true},{"name":"scripts","description":"Scripts will be executed by script runner","icon":"bosch-ic-document-code-stack","copyOnLoad":true,"writeProtected":false},{"name":"trace","description":"Trace: Enabling states - messages, warnings, errors","icon":"bosch-ic-stethoscope","copyOnLoad":true}]},{"name":"rexroth-deviceadmin","title":"Device Admin","version":"2.6.7","appDirectories":[{"name":"diagnosis","description":"Diagnosis settings","icon":"bosch-ic-stethoscope","copyOnLoad":true},{"name":"remote-logging","description":"Log Management settings","icon":"bosch-ic-stethoscope","copyOnLoad":true,"writeProtected":false}]},{"name":"rexroth-ethercatmaster","title":"EtherCAT Master","version":"2.6.2","appDirectories":[{"name":"comm.ethercat.master","description":"EtherCAT master","icon":"ctrlx-ic-ethercat","writeProtected":true}]},{"name":"rexroth-ide","title":"IDE","version":"2.6.2","appDirectories":[{"name":"tiger","description":"IDE: created projects","icon":"bosch-ic-development-kit","copyOnLoad":true}]},{"name":"rexroth-motion","title":"Motion","version":"2.6.4","appDirectories":[{"name":"axisprofile","description":"Motion: Axis profile configuration","icon":"bosch-ic-directory","copyOnLoad":true},{"name":"motion","description":"Motion: Axes and kinematics configuration, coordinate systems and areas","icon":"ctrlx-ic-motion","copyOnLoad":true}]},{"name":"rexroth-opcua-server","title":"OPC UA Server","version":"2.6.1","appDirectories":[{"name":"opcuaserver","description":"OPC UA Server: Endpoint configuration, limit values and certificate configuration","icon":"ctrlx-ic-opc-ua","copyOnLoad":true,"writeProtected":true},{"name":"opcuaserver/cert-import","copyOnLoad":true,"writeProtected":false},{"name":"opcuaserver/companion-config","copyOnLoad":true,"writeProtected":false}]},{"name":"rexroth-plc","title":"PLC","version":"2.6.3","appDirectories":[{"name":"plc","description":"PLC: Runtime and optional engineering data","icon":"ctrlx-ic-plc","copyOnLoad":true,"writeProtected":true},{"name":"plc/run/linux-gcc-aarch64/data","copyOnLoad":true,"writeProtected":false},{"name":"plc/run/linux-gcc-x64/data","copyOnLoad":true,"writeProtected":false}]},{"name":"rexroth-python","title":"Python Runtime","version":"2.6.0"},{"name":"rexroth-setup","title":"Setup","version":"2.6.0"},{"name":"rexroth-solutions","title":"Solutions","version":"2.6.0"},{"name":"sdk-py-appdata","title":"SDK Python App Data","version":"1.0.0","appDirectories":[{"name":"AppDataSamplePy","description":"Python AppData Sample","icon":"bosch-ic-directory","copyOnLoad":true}]},{"name":"snapd","version":"2.61.2"}]},{"name":"test","deploy":{},"modtime":"2024-09-23T18:21:44.489462741Z","device":"VirtualControl-2-6-8","user":"boschrexroth","apps":[{"name":"bare","version":"1.0"},{"name":"core20","version":"20230126"},{"name":"core22","version":"20230801"},{"name":"ctrlx-influxdb","title":"InfluxDB","version":"2.6.0+2.7.5","appDirectories":[{"name":"influxdb","description":"InfluxDB configuration","icon":"bosch-ic-core-data","copyOnLoad":true,"writeProtected":false}]},{"name":"ctrlx-jupyter","title":"ctrlX Jupyter","version":"1.20.0"},{"name":"ctrlx-mosquitto","title":"Mosquitto MQTT Broker","version":"2.0.19","appDirectories":[{"name":"mosquitto","description":"Mosquitto","icon":"bosch-ic-cloud-share","copyOnLoad":true}]},{"name":"ctrlx-node-red","title":"Node-RED","version":"2.6.5+3.1.11-ctrlx","appDirectories":[{"name":"node-RED","description":"Node-RED configuration (userDir)","icon":"bosch-ic-directory","copyOnLoad":true,"writeProtected":false}]},{"name":"ctrlx-smarthmi-webiq-runtime","title":"WebIQ Server App (Runtime App)","version":"2.15.7"},{"name":"ctrlx-telegraf","title":"Telegraf","version":"2.6.1+1.29.4","appDirectories":[{"name":"telegraf","description":"Telegraf configuration","icon":"bosch-ic-chart-line-checkmark","copyOnLoad":true,"writeProtected":false}]},{"name":"rexroth-arch02-engineering","title":"Hardware Support","version":"2.6.2"},{"name":"rexroth-arch02-virtual-kernel","title":"Virtual Kernel","version":"6.1.33-rt11-ctrlx-28.3"},{"name":"rexroth-automationcore","title":"Automation Core","version":"2.6.2","appDirectories":[{"name":"datalayer","description":"Data Layer","icon":"ctrlx-ic-data-layer","copyOnLoad":true},{"name":"scheduler","description":"Scheduler: Tasks, callables and timing settings","icon":"bosch-ic-cycletime-eighth","copyOnLoad":true},{"name":"script","description":"Scripts configurations","icon":"bosch-ic-document-code-stack","copyOnLoad":true},{"name":"scripts","description":"Scripts will be executed by script runner","icon":"bosch-ic-document-code-stack","copyOnLoad":true,"writeProtected":false},{"name":"trace","description":"Trace: Enabling states - messages, warnings, errors","icon":"bosch-ic-stethoscope","copyOnLoad":true}]},{"name":"rexroth-deviceadmin","title":"Device Admin","version":"2.6.7","appDirectories":[{"name":"diagnosis","description":"Diagnosis settings","icon":"bosch-ic-stethoscope","copyOnLoad":true},{"name":"remote-logging","description":"Log Management settings","icon":"bosch-ic-stethoscope","copyOnLoad":true,"writeProtected":false}]},{"name":"rexroth-ethercatmaster","title":"EtherCAT Master","version":"2.6.2","appDirectories":[{"name":"comm.ethercat.master","description":"EtherCAT master","icon":"ctrlx-ic-ethercat","writeProtected":true}]},{"name":"rexroth-ide","title":"IDE","version":"2.6.2","appDirectories":[{"name":"tiger","description":"IDE: created projects","icon":"bosch-ic-development-kit","copyOnLoad":true}]},{"name":"rexroth-motion","title":"Motion","version":"2.6.4","appDirectories":[{"name":"axisprofile","description":"Motion: Axis profile configuration","icon":"bosch-ic-directory","copyOnLoad":true},{"name":"motion","description":"Motion: Axes and kinematics configuration, coordinate systems and areas","icon":"ctrlx-ic-motion","copyOnLoad":true}]},{"name":"rexroth-opcua-server","title":"OPC UA Server","version":"2.6.1","appDirectories":[{"name":"opcuaserver","description":"OPC UA Server: Endpoint configuration, limit values and certificate configuration","icon":"ctrlx-ic-opc-ua","copyOnLoad":true,"writeProtected":true},{"name":"opcuaserver/cert-import","copyOnLoad":true,"writeProtected":false},{"name":"opcuaserver/companion-config","copyOnLoad":true,"writeProtected":false}]},{"name":"rexroth-plc","title":"PLC","version":"2.6.3","appDirectories":[{"name":"plc","description":"PLC: Runtime and optional engineering data","icon":"ctrlx-ic-plc","copyOnLoad":true,"writeProtected":true},{"name":"plc/run/linux-gcc-aarch64/data","copyOnLoad":true,"writeProtected":false},{"name":"plc/run/linux-gcc-x64/data","copyOnLoad":true,"writeProtected":false}]},{"name":"rexroth-python","title":"Python Runtime","version":"2.6.0"},{"name":"rexroth-setup","title":"Setup","version":"2.6.0"},{"name":"rexroth-solutions","title":"Solutions","version":"2.6.0"},{"name":"sdk-py-appdata","title":"SDK Python App Data","version":"1.0.0","appDirectories":[{"name":"AppDataSamplePy","description":"Python AppData Sample","icon":"bosch-ic-directory","copyOnLoad":true}]},{"name":"snapd","version":"2.61.2"}]}]

 

 

If you run this in a debugger and break on the response, can you view all of the data? Is it possible you have a character limit set on your print function?

What version of the VirtualCORE and Python requests lib are you using?

I would recommend using the datalayer client class rather than raw REST API for any datalayer operations.

Hey @Sgilk,

I tried testing it with the remote debugging instead of uploading it to the core and it immediately worked! It actually sends and prints out everything as you would expect. I didn't change anything in the print function but you might be onto something. There might be some kind of character limit in there for some reason.

Thanks for helping!

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist