Hi Forums
I have been trying to work with this snippet but seems like I can't get it just right. I have added an explain here below as I can't post an image of what I'm trying to achieve.
This should send the XML commands to my server API and initiate an Environment called "Animals.hwe" to be shown on a videowall.
http. ..... ://192.168.0.196:8000/xmlcommand .................... POST
Use Custom HTTP body - HTTPBody:
POST /xmlcommand
Response time: 24 ms
Request Headers & Body
Accept: */*
Accept-Encoding: gzip, deflate
Content-Type: text/plain
Accept-Language: en-us
Response Headers
HTTP/1.1 200 OK
Date: Tue, 27 Oct 2020 18:03:53 GMT
Cache-Control: no-cache
Transfer-Encoding: Identity
Not sure what goes wrong in my code but seems like the XML code does not reach the server API correctly.
Any ideas would be greatly appreciated.
Thanks
Michael
I have been trying to work with this snippet but seems like I can't get it just right. I have added an explain here below as I can't post an image of what I'm trying to achieve.
This should send the XML commands to my server API and initiate an Environment called "Animals.hwe" to be shown on a videowall.
note: the xmlcommand URL is changed because of the http not being allowed.
My test code...
Code Block import UIKit import SwiftUI let session = URLSession(configuration: .default) let url = URL(string: "http........://192.168.0.196:8000/xmlcommand") var request = URLRequest(url: url) request.httpMethod = "POST" request.httpBody = "<?xml version=\"1.0\"encoding=\"UTF-8\"?><Commands><command> type=\"open\"><name>environments/Animals.hwe</name><id>a1</id></command></Commands>".data(using: .utf8) let task = session.dataTask(with: request) { data, response, error in // do something with the result } task.resume() // <- otherwise your network request won't be started
With Rested App on Mac I can make the "POST" work fine with these settings:
http. ..... ://192.168.0.196:8000/xmlcommand .................... POST
Use Custom HTTP body - HTTPBody:
Code Block <?xml version="1.0" encoding="UTF-8"?> <Commands> <command type="open"> <name>environments/Animals.hwe</name> <id>a1</id> </command> </Commands>
Result from Rested application that works with the XML code...
POST /xmlcommand
Response time: 24 ms
Request Headers & Body
Accept: */*
Accept-Encoding: gzip, deflate
Content-Type: text/plain
Accept-Language: en-us
Code Block <?xml version="1.0" encoding="UTF-8"?> <Commands> <command type="open"> <name>environments/Animals.hwe</name> <id>a1</id> </command> </Commands>
Response Headers
HTTP/1.1 200 OK
Date: Tue, 27 Oct 2020 18:03:53 GMT
Cache-Control: no-cache
Transfer-Encoding: Identity
Not sure what goes wrong in my code but seems like the XML code does not reach the server API correctly.
Any ideas would be greatly appreciated.
Thanks
Michael