lib/external/audio_harvester.rb
def create_new_audiorecording(post_params)
      Net::HTTP.start(@host, @port) do |http|

        auth_token = request_login(http)

        if auth_token
          new_params = post_params.clone
          new_params[:auth_token] = auth_token

          create_post = construct_post(@endpoint_create,new_params)
          logger.debug "Create request: #{create_post.inspect}, Body: #{create_post.body}"

          response = http.request(create_post)
          logger.debug "Create response: #{response.code}, Message: #{response.message}, Body: #{response.body}"

          if response.code == '201'
            response_json = JSON.parse(response.body)
            Logging.logger.info 'New audio recording created.'
            response
          elsif response.code == '422'
            Logging.logger.error "Login request was not valid (Unprocessable Entity): code #{response.code}, Message: #{response.message}, Body: #{response.body}"
          else
            Logging.logger.error "Create response was not recognised: code #{response.code}, Message: #{response.message}, Body: #{response.body}"
            nil
          end
        else
          Logging.logger.error "Login response, expected 200 OK, got #{response.code}, Message: #{response.message}, Body: #{response.body}"
          nil
        end
      end
    end
# get uuid for audio recording from website via REST API
# If you post to a Ruby on Rails REST API endpoint, then you'll get an
# InvalidAuthenticityToken exception unless you set a different
# content type in the request headers, since any post from a form must
# contain an authenticity token.

get uuid for audio recording from website via REST API
If you post to a Ruby on Rails REST API endpoint, then you'll get an
InvalidAuthenticityToken exception unless you set a different
content type in the request headers, since any post from a form must
contain an authenticity token.
get uuid for audio recording from website via REST API If you post to a Ruby on Rails REST API endpoint then you ' ll get an InvalidAuthenticityToken exception unless you set a different content type in the request headers since any post from a form must contain an authenticity token .
def create_new_audiorecording(post_params)
      Net::HTTP.start(@host, @port) do |http|
        auth_token = request_login(http)
        if auth_token
          new_params = post_params.clone
          new_params[:auth_token] = auth_token
          create_post = construct_post(@endpoint_create,new_params)
          logger.debug "Create request: #{create_post.inspect}, Body: #{create_post.body}"
          response = http.request(create_post)
          logger.debug "Create response: #{response.code}, Message: #{response.message}, Body: #{response.body}"
          if response.code == '201'
            response_json = JSON.parse(response.body)
            Logging.logger.info 'New audio recording created.'
            response
          elsif response.code == '422'
            Logging.logger.error "Login request was not valid (Unprocessable Entity): code #{response.code}, Message: #{response.message}, Body: #{response.body}"
          else
            Logging.logger.error "Create response was not recognised: code #{response.code}, Message: #{response.message}, Body: #{response.body}"
            nil
          end
        else
          Logging.logger.error "Login response, expected 200 OK, got #{response.code}, Message: #{response.message}, Body: #{response.body}"
          nil
        end
      end
    end
def create_new_audiorecording ( post_params ) Net :: HTTP . start ( @host , @port ) do | http | auth_token = request_login ( http ) if auth_token new_params = post_params . clone new_params [ :auth_token ] = auth_token create_post = construct_post ( @endpoint_create , new_params ) logger . debug "Create request: #{create_post.inspect}, Body: #{create_post.body}" response = http . request ( create_post ) logger . debug "Create response: #{response.code}, Message: #{response.message}, Body: #{response.body}" if response . code == '201' response_json = JSON . parse ( response . body ) Logging . logger . info 'New audio recording created.' response elsif response . code == '422' Logging . logger . error "Login request was not valid (Unprocessable Entity): code #{response.code}, Message: #{response.message}, Body: #{response.body}" else Logging . logger . error "Create response was not recognised: code #{response.code}, Message: #{response.message}, Body: #{response.body}" nil end else Logging . logger . error "Login response, expected 200 OK, got #{response.code}, Message: #{response.message}, Body: #{response.body}" nil end end end
get uuid for audio recording from website via REST API
If you post to a Ruby on Rails REST API endpoint, then you'll get an
InvalidAuthenticityToken exception unless you set a different
content type in the request headers, since any post from a form must
contain an authenticity token.
get uuid for audio recording from website via REST API If you post to a Ruby on Rails REST API endpoint then you ' ll get an InvalidAuthenticityToken exception unless you set a different content type in the request headers since any post from a form must contain an authenticity token .
post_params