My Products
Help
Anonymous
Not applicable

Problem med å hente

by Anonymous

Jeg bruker den koden jeg har brukt lenge, og som har funket.

_restRequest = new RestRequest("API/security/api/v2/token", Method.POST);
_restRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
_restRequest.AddHeader("Accept", "application/json");
_restRequest.AddHeader("ipp-application-type", _ippApplicationType);
_restRequest.AddHeader("ipp-company-id", _ippCompanyId);
_restRequest.AddParameter("grant_type", "password");
_restRequest.AddParameter("client_id", _client_id);
_restRequest.AddParameter("client_secret", _client_secret);
_restRequest.AddParameter("username", _username);
_restRequest.AddParameter("password", _password);
IRestResponse response = new RestClient(_url).Execute(_restRequest);
_statusCode = response.StatusCode.ToString();
if (_statusCode == "OK")
{
string content = response.Content;
VismaSecurityToken myToken = JsonConvert.DeserializeObject<VismaSecurityToken>(content);
_token = "Bearer " + myToken.token;
}

response.StatusCode.ToString(); gir "0". Betyr det at brukeren min ikke har rette rettigheter?

 

9 REPLIES 9
Anonymous
Not applicable

by Anonymous

I have used Swagger to test to test various endpoints. But I was not aware that I can use it to obtain Tolken. How do I do that

Anonymous
Not applicable

by Anonymous

As seen in the code, I use the endpoint API/security/api/v2/token. And the Method POST.
I can not find this endpoint in swagger

Anonymous
Not applicable

by Anonymous

I thought the problem was related to what rights the user has,
but I have now tried with parameters I use for another customer.
I'm getting the same problem.
This is code I have used for several to without any problems.

by Magnus Johnsen (Updated ‎09-11-2020 08:10 by Magnus Johnsen VISMA )

If you can send your API-Client-ID to developersupport@visma.com we can check with the VNI team if there are any issues with your client.

 

Thank you. 

Anonymous
Not applicable

by Anonymous

developersuppor@visma.com is not accepted as an email address.
API-Client-ID: proplan​

 

by Magnus Johnsen

Hi,

Sorry missed a "t", we'll check and get back to you. 

Accepted solution
Anonymous
Not applicable

by Anonymous

The problem was solved by VNI-Support Ticket 1823568T

Hi!
I have to apologize. I used the wrong URL.
I used //integration.visma.net/API/security/api/v2/token.
I now use https://integration.visma.net/API/security/api/v2/token
I was not concentrating on that. I was sure there were no changes here.
Thanks for your help

​Regards
Dag Grønvold

Yıldırım
VISMA

by Yıldırım (Updated ‎10-11-2020 11:08 by Yıldırım VISMA )

Hello Dag,
glad to hear the issue has been resolved and it was only connected to missing https.

by Magnus Johnsen (Updated ‎06-11-2020 16:17 by Magnus Johnsen VISMA )

Hi,

 

Please be aware that this forum is international and with regards to this the communication is done in English.

Unfortunately, our support does not cover code support as specified in our terms, more information regarding practises in this forum can be found here: 

 

Regarding the response, a status code of '0' should never be returned. It should return a proper HTTP status code.

Please also have a look at this article:

Could you please try to authenticate in Swagger and/or Postman and share your results?