API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Ruby Rest-Client for writing invoice API

Hi all,

I'm new to Ruby and trying to use the Ruby gem 'rest-client' to access the REST API of my accounting system, e-conomic.com. I am able to connect via tokens and e.g. fetch customer details - so far, so good.

However, I'm struggling to figure out how to POST and thus create a new customer entry with e.g. address, name, mail etc.. In particular, I'm looking to get the code to both include my authentication token details (i.e. content of hHeader below), while also including a payload of customer details.

Details about the customer creation via the REST API:

Details about the rest-client ruby gem:

I'm running Ruby 2.3.3 on Windows 7 in the Atom editor.
My code is as below:

    Dir.chdir 'C:\Ruby23\bin'
    require 'rest-client'
    require 'rconomic'
    require 'json'
    hHeader = {"X-AppSecretToken" => 'tokenID1_sanitized', "X-AgreementGrantToken" => 'tokenID2_sanitized', "Content-Type" => 'application/json'}
    hCustomer = RestClient.get("https://restapi.e-conomic.com/customers/5", hHeader) # => creates a response showing customer 5 (shown for example of GET)

Your input would be much appreciated!

created Mar 5, 2017 by Mar
0% Accept Rate
Q 2 A 0 C 0

Visma e-conomic A/S