Closed Voxar closed 10 years ago
@Voxar , can you please run your code with logger?
To configure logger: require 'logger' l = Logger.new($stderr) l.level = 0 sl.log = l
I cannot reproduce your error, so would like to see logs of your http requests.
@Voxar also: file .pos should be reset to 0 before reading, I believe. Check with rest-client.
up: this should not matter, since you are passing file path, not the stream.
api key and project id redacted
RestClient.post "https://sandbox-api.smartling.com/v1/file/upload?apiKey=<REDACTED>&projectId=<REDACTED>&fileUri=test/simple_json_file.json&fileType=json", "--513915\r\nContent-Disposition: form-data; name=\"file\"; filename=\"json20131022-64970-8ax3jb\"\r\nContent-Type: text/plain\r\n\r\n{\"key\":\"value\"}\r\n--513915--\r\n", "Accept"=>"*/*; q=0.5, application/xml", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"150", "Content-Type"=>"multipart/form-data; boundary=513915"
"--513915\r\nContent-Disposition: form-data; name=\"file\"; filename=\"json20131022-64970-8ax3jb\"\r\nContent-Type: text/plain\r\n\r\n{\"key\":\"value\"}\r\n--513915--\r\n"
# => 400 BadRequest | application/json 84 bytes
/Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/smartling-0.5.1/lib/smartling/api.rb:53:in `check_response': API error: VALIDATION_ERROR File is required (RuntimeError)
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/smartling-0.5.1/lib/smartling/api.rb:57:in `process'
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/smartling-0.5.1/lib/smartling/api.rb:90:in `block in post'
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/rest-client-1.6.7/lib/restclient/request.rb:229:in `call'
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/rest-client-1.6.7/lib/restclient/request.rb:229:in `process_result'
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/rest-client-1.6.7/lib/restclient/request.rb:179:in `block in transmit'
from /Users/voxar/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:745:in `start'
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/rest-client-1.6.7/lib/restclient.rb:72:in `post'
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/smartling-0.5.1/lib/smartling/api.rb:89:in `post'
from /Users/voxar/.rvm/gems/ruby-1.9.3-p327/gems/smartling-0.5.1/lib/smartling/fileapi.rb:53:in `upload'
from smartling lib error test.rb:15:in `<main>'
@paiv Are streams supported? StringIO object doesn't work, thus the tempfile.
@Voxar could you confirm that body request is duplicated in your logs?
RestClient.post "https://sandbox-api.smartling.com/v1/file/upload?apiKey=&projectId= &fileUri=test/simple_json_file.json&fileType=json", "--513915\r\nContent-Disposition: form-data; name=\"file\"; filename=\"json20131022-64970-8ax3jb\"\r\nContent-Type: text/plain\r\n\r\n{\"key\":\"value\"}\r\n--513915--\r\n", "Accept"=>"*/*; q=0.5, application/xml", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"150", "Content-Type"=>"multipart/form-data; boundary=513915" "--513915\r\nContent-Disposition: form-data; name=\"file\"; filename=\"json20131022-64970-8ax3jb\"\r\nContent-Type: text/plain\r\n\r\n{\"key\":\"value\"}\r\n--513915--\r\n"
I noticed the second occurrence did not print to stderr so I started suspecting something might be wrong with gems. I reinstalled and it works now -.-
Thank you for your help.
api.rb:53: in `check_response': API error: VALIDATION_ERROR File is required (RuntimeError)