Errors registering alert endpoint


#1

I keep getting the error


Savon::SOAPFault: (CLIENT) INVALID: unsupported format_type

even though I have it set to “json/post”

The ruby code that I am using is


response = client.call(:register_alert_endpoint, message: {address: 'http://www.whatever.com/flightaware.json', format_type: "json/post"})

Other API calls work perfectly in the same manner, so it seems like it is expecting something else in the format_type field even though the documentation explicitly states that “json/post” is the only valid option.


#2

The second argument is not getting passed to us properly for some reason. It is being parsed as a missing/blank argument, so it is being rejected for that reason.


#3

So none of the attempts that I made are actually sending the format_type? That seems very odd since I included it. Do you have any advice on how to fix this?


#4

Can you try something more similar to our Savon example:



result = client.request(:register_alert_endpoint) do
  soap.body = {
    :address => 'http://www.whatever.com/flightaware.json',
    :format_type => 'json/post'
  }
end



#5

That code does not work with the current version of Savon. I am using Savon 2. For more information look at savonrb.com/version2/requests.html


#6

I got it to work with:


response = client.call(:register_alert_endpoint, message: { address: 'http://test.com/flightaware.json', format__type: 'json/post'})


It seems like savon adds an extra

_

and was just throwing out what it assumed was an invalid key


#7

Were you looking at the raw SOAP request body that Savon was generating to figure that out? Are you saying this is a bug in Savon 2?


#8

Yeah. It is a bug in the way Savon 2 names parameters and handles not valid named keys in the message hash. Thanks for telling me that the parameter was not being sent at all. Without that information it would have been much harder to find the bug.


#9

Have you filed a bug report against Savon 2, if one doesn’t exist already? Or is there something we should be defining differently in our WSDL?


#10

My guess is that it is just the way that Savon tries to clean up function names from the WSDL file to make them more like ruby hash keys. It probably adds an extra ‘_’ and since they are working on a new version I was just going to manually add the extra underscore in my code for now and update when the new version is ready. It might fix it if the WSDL file defined the parameters like “FormatType” instead of “format_type”, but I don’t think it is worth the effort of fixing this corner case if I am the only one that actually noticed the problem.