Skip to content

Commit d1495e8

Browse files
added basic retry function
1 parent 975459e commit d1495e8

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/main/java/unicon/matthews/dataloader/MatthewsClient.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,17 @@ public void postUser(User user) {
134134
String path = "/api/users";
135135
String url = this.baseUrl + path;
136136

137-
restTemplate
137+
ResponseEntity<JsonObject> response =
138+
restTemplate
138139
.exchange(url, HttpMethod.POST, he, JsonObject.class);
140+
141+
142+
if (response != null && response.getStatusCode() == HttpStatus.FORBIDDEN) {
143+
httpHeaders.add("Authorization", "Bearer "+ getToken());
144+
restTemplate
145+
.exchange(url, HttpMethod.POST, he, JsonObject.class);
146+
}
147+
139148
}
140149

141150
public void postUserMapping(UserMapping userMapping) {

0 commit comments

Comments
 (0)