I’m using the Trimble Connect API to import/export objects to/from SketchUp, but recently ran into some issue when calling HTTP requests with the SketchUp::Http module. All the other calls I’ve tried so far work fine, but there is one where I have to send the request body as json raw and I can’t make it work. Tried with Postman and it works fine, so the configuration is ok. See below the request documentation and my code:
Then also use a tool like Fiddler to capture the HTTP traffic and compare the requests for their differences:
If you cannot get any requests to work you should reach out to Trimble Connect support and see if you’ve run into issues with their API or documentation.
@DanRathbun That doesn’t work either, I have another requests with that same convention and they work, the issue is in the body. I’ve tried many configurations, but the response is always the same.
@tt_su I have tried with Postman (in fact I mentioned it in the post), and it works. From Ruby I’m getting a Message Exception, so the body is wrong. I also contacted with TC but they cannot help me with the Ruby piece. See below the Postman captures to compare with the code. The call (header and body) is the same, but it’s working in Postman (Status 204) and not with Sketchup::Http (Status 400 and MessageException).
Also, I have noticed and posted that the SketchUp Http classes do NOT work the same as Net::HTTP classes with respect to capitalization of header fields and names of methods.
Using exact matching capitalization is especially important when testing response headers.
But the code is crashing in the res = http.request(req) line, so there is something wrong too… The surrounding array is the thing that annoys me most, but it has to be included in the body to get the right response, as you can see in the capture of my previous post. See below a failed test without the [,] brackets.
@tt_su I used Fiddler but I can only see the traffic whose response is HTTP 200. The HTTP 204 or HTTP 400 responses don’t show up, neither from Postman nor from the extension. Other requests that I’m calling and are correct are showing up, see below.