1

Data type error


Avatar
Morten Fahrnholz

Hi, you are not answering questions in the API discussion page. We have a problem. When returning a charge, you return an id (e.g. 631434965834520200)

This is not the excpected int16, but I was able to update my code to cover this. However, If we try to stop the charge at
public-api.monta.com/api/v1/charges/{chargeId}/stop it failes. The problem is at your end. The result:

{
"status": "NOT_FOUND",
"message": "Charge with ID `631434965834520200` not found.",
"readableMessage": "Not Found",
"errorCode": "RESOURCE_NOT_FOUND",
"context": null
}

A

Activity Newest / Oldest

Avatar

Christian Weinberger

Hi Morten,

Yes we have changed our IDs (Sorry for the inconveniences), however, they still conform to the api docs specification: Int64

I assume you are using a JavaScript based framework for parsing our response. Especially older versions do not deal properly with Int64.

631434965834520200 looks like something that overflew.

You can find an example how Int64 is handled differently on JS here: jsfiddle.net/5vzk7yp2/

So you probably have to change your implementation to use BigInt.

Best,
Christian


Avatar

Morten Fahrnholz

Hi Christian,
Thanks, actually I'm using C# and have updated my code to use Int64. GET requests is working.
My model working fine when parsing
public class Charge
{
public Int64 id { get; set; }
....
}

No luck when posting public-api.monta.com/api/v1/charges/Int64/stop though. Also not working at your site docs.public-api.monta.com/reference/stop-charge


Avatar

Christian Weinberger

We have tested this internally - should work.

Yes, in the "try-out" section it does currently not work (the software does not properly support BigInt, we raised a ticket with the provider).

Can you share your charge id and charge point id?


Avatar

Morten Fahrnholz

Sure,
Charge point id: 2965391
Charge id: 631723348854823400

This is not working (404 status code)

var client = _httpClientFactory.CreateClient("MontaHttpClient");
var token = await Helpers.MontaAuthHelper.GetAccessToken(client);
var intCharge = Int64.Parse(chargeId);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.accessToken);

var url = $"public-api.monta.com/api/v1/charges/{intCharge}/stop";
var response = await client.PostAsync($"{url}",null);
if (response.IsSuccessStatusCode)
{
return true;
}

return false;


Avatar

Morten Fahrnholz

Hi Christian,
Any news regarding this? It's still not working


Avatar

Christian Weinberger

Sorry Morten,

The issue has been answered in Discussions page btw: docs.public-api.monta.com/discuss/66fbaebd584747002b1fd724

The charge you are trying to stop does not exist. You are probably not handling Int64 properly in GET /charges endpoint.


Avatar

Morten Fahrnholz

Hi Christian,
Not working. I'm getting the same charge id as the API docs site.

For example:
Charge Id = 635367875366797300
When trying to stop, I get Not Found.

I know how to parse the id as Int64 when getting the charge ;)


Avatar

Christian Weinberger

The API docs site "Try Me" functionality suffers from the same issue with BigInts (already raised with the vendor).


Avatar

Morten Fahrnholz

Still, I've tried both Int64 and long datatypes in C#, and it's not working.
Can you get me the latest chargeId from the charger with id 2965391 ? Then I can compare with what I'm getting when i query the API


Avatar

Christian Weinberger

Sure, last 3 IDs:
- 636115506940911769
- 636089323350432881
- 634974495046134757


Avatar

Morten Fahrnholz

Thanks, I got it working now. The reason was that the Microsoft extension method ReadAsAsync() somehow modifies the values when serializing into Int64... Solution was to serialize the id as a string and then parse it to Int64 before posting to the stop charge endpoint.

Thanks for your help.