|
Hi Scott,
After getting in touch with the Vertex Cloud technical team, they provided
the following explanation and Javascript solution. Does your tool have a
solution for this?
The Authentication server is not going to be compatible with the RAW JSON
at this moment because this is throwing a security flag from our auth
server. The authentication process that will have to be implemented into
your client in order to get the accessToken should look something like the
following Javascript:
public OAuthResponse getAccessToken() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String,String> map = new LinkedMultiValueMap<>();
map.add("client_id", "1c2fxxxx-xxxx-xxxx-xxxx-xxxx9a5b2474");
map.add("client_secret", "e645xxxx-xxxx-xxxx-xxxx-xxxxaf9a317c");
map.add("grant_type", "password");
map.add("username", "c7ddxxxx-xxxx-xxxx-xxxx-xxxx6a8a32b1");
map.add("password", "a6adxxxx-xxxx-xxxx-xxxx-xxxx22c0b8d7");
map.add("scope", "calc-rest-api");
HttpEntity<MultiValueMap<String,String>> entity = new
HttpEntity<>(map, headers);
ResponseEntity<OAuthResponse> response;
OAuthResponse oAuthResponse = null;
try {
response = restTemplate.postForEntity(oauthUrl, entity,
OAuthResponse.class);
oAuthResponse = response.getBody();
} catch (HttpClientErrorException e) {
if (e.getStatusCode().value() >= 400) {
return
refreshAccessToken("350630f9-4b6e-47cf-86e3-c1682fcb4ed5");
} else {
String msg = String.format("error while communicating with
auth server: %s", e.getMessage());
throw new GeneralAuthServerException(msg);
}
} catch (Exception e) {
String msg = String.format("error while communicating with
auth server: %s", e.getMessage());
throw new GeneralAuthServerException(msg);
}
if (oAuthResponse == null) {
throw new GeneralAuthServerException("OAuth server returned
invalid response");
} else {
return oAuthResponse;
}
}
Ron Hudson | Programmer / Analyst
+1.704.752.6513 x1324
www.invue.com
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Scott
Klement
Sent: Wednesday, April 3, 2019 11:45 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: REST request to Vertex Cloud
Ron,
I am not familiar with 'Vertex Cloud' and hadn't heard of it prior to your
post.
The data you're sending is a JSON document, so the correct content-type
would be 'application/json'. You say that gives you a 415 response, which
makes me think I'm missing something in how this is supposed to work.
You say you tried 'x-www-form-urlencoded' but that is not a valid media
type at all. You probably meant 'application/x-www-form-urlencoded',
which is the default media type for HTML form data. (However, your JSON
document is not HTML form data, at least not the way you've coded it.)
If you can tell me how you're supposed to send it, I could tell you how to
do it in HTTPAPI. But, I can't figure it out from the info you've supplied.
-SK
On 4/3/19 10:28 AM, Hudson, Ron wrote:
Has anyone had success using a REST request to the Vertex Cloud forsales tax calculations? If so, any advice? Vertex has been of little
help, all their IBM i connections are SOAP.
either 400 Bad Request or 415 Unsupported Media Type , depending on what
I'm attempting to use Scott's HTTPAPI version 1.39, O/S version V7R3M0.
The debug log shows I am making the connection, but I am receiving
"Content-Type" is sent.
Testing the connection with Postman is successful.(this was successful in Postman)
Entire test program below:
http_debug(*on: '/tmp/debug.txt');
JSONsecurity = '+
{"client_id":"Rest-API-xxxxxxxxxxxxxxxxx",+
"client_secret":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",+
"username":"xxxxxxxxxxxxxx",+
"password":"xxxxxxxxxx",+
"scope":"calc-rest-api",+
"grant_type":"password"}';
URL = 'https://auth.vertexsmb.com/identity/connect/token';
monitor;
resp= http_string('POST': url : JSONsecurity :
'x-www-form-urlencoded'); on-error;
httpcode = http_error();
endmon;
*inlr = *on;
Results from different "Content-Type" below
// 'x-www-form-urlencoded' 400 Bad Request
// 'application/json' 415 Unsupported Media TypeType
// 'accept: text/json' 400 Bad Request
// 'text/json' 415 Unsupported Media
// 'text/plain' 415 Unsupported Media Type
// 'accept: text/plain' 400 Bad Request
Thanks
Ron
--
Scott Klement
http://www.scottklement.com
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.