Method: Frodo::Concerns::API#create!
- Defined in:
- lib/frodo/concerns/api.rb
#create!(entity_set_name, attrs) ⇒ Object Also known as: insert!
Public: Insert a new record.
entity_set_name - The set the entity belongs to attrs - Hash of attributes to set on the new record.
Examples
# Add a new lead
client.create!('leads', {"firstname" =>'Bob'})
# => '073ca9c8-2a41-e911-a81d-000d3a1d5a0b'
Returns the primary key value of the newly created entity. Raises exceptions if an error is returned from Dynamics.
111 112 113 114 115 116 117 118 119 |
# File 'lib/frodo/concerns/api.rb', line 111 def create!(entity_set_name, attrs) url = api_post(entity_set_name, attrs).headers['odata-entityid'] id_match = url.match(/\((.+)\)/) if id_match.nil? raise Frodo::Error.new "entity url not in expected format: #{url.inspect}" end return id_match[1] end |