2

I have a grape API and as part of a POST request I am passing a string that has a '+' as part of it (it's a phone number). Grape seems to be removing the + and replacing it with a blank space.

module V1
  class CustomerDetails < Grape::API
    before do
      error!("Unauthorized", 401) unless authenticated?
    end

    resource :customer_details do

      desc 'Update customer number'
      post anchor: false do
        params do
          requires :customer_id, type: String
          requires :customer_number, type: String
        end

        # Current behaviour: 
        # params[:customer_number] here will be ' 441920765847'

        # Expected behaviour: 
        # params[:customer_number] here will be '+441920765847'

      end
    end
  end
end

I expect to use postman to make the http POST request, with the parameter customer_number with value +441920765847and it does not lose the + (i.e. does not show as 441920765847.

Robert Faldo
  • 401
  • 7
  • 15

1 Answers1

0

solved! It was postman removing it because i was sending it in the params (url string) and not in the body

Robert Faldo
  • 401
  • 7
  • 15