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

REST: A customer needs to be associated with a customer group.

0
Hi

I am trying to create a customer with the REST API, https://restapi.e-conomic.com/customers
 
I post this JSON

{
"customerNumber": 25,
"currency": "DKK",
"paymentTerms": {
"paymentTermsNumber": 1,
"paymentTermsType": 0,
},
"customerGroup": {
"customerGroupNumber": 1,
},
"address": "ATT: test firma 1 test sted ",
"city": "Frederiksberg",
"country": "Danmark",
"email": "test@test.dk",
"name": "testvej 1",
"zip": "2000",
"vatZone": {
"vatZoneNumber": 1,
}
}

But I get a error back
{
"message": "Could not create customer . A customer needs to be associated with a customer group."
"errorCode": "E04042"
"developerHint": "Define a value for customerGroupNumber. You can find a collection of customer groups at /customer-groups"
"logId": "49e7d114ac4d82f360a1661e110e3327"
"httpStatusCode": 400
"logTime": "2016-05-12T13:26:34"
}

 

And customerGroupNumber "1" does exists. 

 

Best regards

Jimmy

created May 12, 2016 by esso
50% Accept Rate
Q 4 A 0 C 5

1 Answer

0
 
Best answer

Hi Jimmy

Your JSON returns message": "Ambiguous references to paymentTerms"

"paymentTerms": {

"paymentTermsNumber": 1,
"paymentTermsType": 0,
}
 
If I change that to
"paymentTerms": {
"paymentTermsNumber": 1,
},
and POST it then there's no issues at all.
 
answered May 12, 2016 by olej
selected May 17, 2016 by esso
Hi, thanks for the answers, but I still get the same error, the JSON I post is now

{
    "customerNumber": 1010,
    "currency": "DKK",
    "paymentTerms": {
        "paymentTermsNumber": 1,
        "self": "https://restapi.e-conomic.com/payment-terms/1"
    },
    "customerGroup": {
        "customerGroupNumber": 1,
        "self": "https://restapi.e-conomic.com/customer-groups/1"
    },
    "address": "ATT: test firma 1 test sted ",
    "city": "Frederiksberg",
    "country": "Danmark",
    "email": "test@test.dk",
    "name": "testvej 1",
    "zip": "2000",
    "vatZone": {
        "vatZoneNumber": 1,
        "self": "https://restapi.e-conomic.com/vat-zones/1"
    }
}
Hi Jimmy.
I'm POSTing your exact JSON without any issues whatsoever.
Could you please log your HTTP request and share the raw request including headers (but please anonymise tokens first  ;-) ).
Fiddler is a great free tool that can do this.
Hi, I am using the Chrome Advanced REST client to test, is this what you are asking for?

I have replace the appid and accessid:

POST /customers HTTP/1.1
 HOST: restapi.e-conomic.com
 appid: XXXX
 accessid: XXXX
 content-length: 460
 
 {"customerNumber":1010,"currency":"DKK","paymentTerms": {"paymentTermsNumber": 1,"self": "https://restapi.e-conomic.com/payment-terms/1"},"customerGroup":{"customerGroupNumber":1,"self":"https://restapi.e-conomic.com/customer-groups/1"},"address":"ATT: test firma 1 test sted ","city":"Frederiksberg","country":"Danmark","email":"test@test.dk","name":"testvej 1","zip":"2000","vatZone":{"vatZoneNumber":1,"self":"https://restapi.e-conomic.com/vat-zones/1"}}


If I "GET", this endpoint https://restapi.e-conomic.com/customer-groups/1 then it returns the correct JSON result.

It is a economics 14 days demo with data i am using.
Do you get the same issue if you use POSTman instead? The latest changes to "Advanced REST Client" have unfortunately been less than stellar in our experience.
It seems to work with Postman. Thank you for help.

Best regards

Jimmy
Visma e-conomic A/S
...