Exception : /engine-rest/external-task/fetchAndLock HTTP/1.1' returned error: status code '302' - message: status code: 302

we have tried to integrate the below git example in our existing spring boot application.

we are getting the following exception

org.camunda.bpm.client.impl.EngineClientException: TASK/CLIENT-02001 Request 'POST http://localhost:8080/camunda-test/engine-rest/external-task/fetchAndLock HTTP/1.1' returned error: status code '302' - message: status code: 302
	at org.camunda.bpm.client.impl.EngineClientLogger.exceptionWhileReceivingResponse(EngineClientLogger.java:30) ~[camunda-external-task-client-7.15.0.jar:7.15.0]
	at org.camunda.bpm.client.impl.RequestExecutor.executeRequest(RequestExecutor.java:97) ~[camunda-external-task-client-7.15.0.jar:7.15.0]
	at org.camunda.bpm.client.impl.RequestExecutor.postRequest(RequestExecutor.java:74) ~[camunda-external-task-client-7.15.0.jar:7.15.0]
	at org.camunda.bpm.client.impl.EngineClient.fetchAndLock(EngineClient.java:80) ~[camunda-external-task-client-7.15.0.jar:7.15.0]
	at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.fetchAndLock(TopicSubscriptionManager.java:135) [camunda-external-task-client-7.15.0.jar:7.15.0]
	at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.acquire(TopicSubscriptionManager.java:101) [camunda-external-task-client-7.15.0.jar:7.15.0]
	at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.run(TopicSubscriptionManager.java:87) [camunda-external-task-client-7.15.0.jar:7.15.0]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_73]

Please help us to resolve the above 302 exception.

Added the following Gradle dependencies

// https://mvnrepository.com/artifact/org.camunda.bpm.springboot/camunda-bpm-spring-boot-starter-webapp
	implementation group: 'org.camunda.bpm.springboot', name: 'camunda-bpm-spring-boot-starter-webapp', version: '7.15.0'
	
	// https://mvnrepository.com/artifact/org.camunda.bpm.springboot/camunda-bpm-spring-boot-starter-external-task-client
	implementation group: 'org.camunda.bpm.springboot', name: 'camunda-bpm-spring-boot-starter-external-task-client', version: '7.15.0'
	
	// https://mvnrepository.com/artifact/org.camunda.bpm.springboot/camunda-bpm-spring-boot-starter-rest
	implementation group: 'org.camunda.bpm.springboot', name: 'camunda-bpm-spring-boot-starter-rest', version: '7.15.0'
	
	// https://mvnrepository.com/artifact/org.camunda.bpm/camunda-engine-plugin-spin
	implementation group: 'org.camunda.bpm', name: 'camunda-engine-plugin-spin', version: '7.15.0'
	
	// https://mvnrepository.com/artifact/org.camunda.spin/camunda-spin-dataformat-all
	implementation group: 'org.camunda.spin', name: 'camunda-spin-dataformat-all', version: '1.10.1'

if we try to run git example directly with the mvn spring-boot:run, the example is working fine.

But when we try to integrate the git example in our spring boot application its getting 302 error

environment details: java 1.8
spring boot 2.3.12.RELEASE
database: mysql
spring-security: true

Why are you including the external task client?

@Niall , i followed the above git repository

@Configuration
public class HandlerConfiguration {
  
  protected static Logger LOG = LoggerFactory.getLogger(HandlerConfiguration.class);

  protected String workerId;

  public HandlerConfiguration(ClientProperties properties) {
    workerId = properties.getWorkerId();
  }

  @ExternalTaskSubscription("creditScoreChecker")
  @Bean
  public ExternalTaskHandler creditScoreChecker() {
    return (externalTask, externalTaskService) -> {

      // retrieve a variable from the Process Engine
      int defaultScore = externalTask.getVariable("defaultScore");

      List<Integer> creditScores = new ArrayList<>(Arrays.asList(defaultScore, 9, 1, 4, 10));

      // create an object typed variable
      ObjectValue creditScoresObject = Variables.objectValue(creditScores).create();

      // complete the external task
      externalTaskService.complete(externalTask, Variables.putValueTyped("creditScores", creditScoresObject));

      LOG.info("{}: The External Task {} has been checked!", workerId, externalTask.getId());
    };
  }

  @ExternalTaskSubscription("loanGranter")
  @Bean
  public ExternalTaskHandler loanGranter() {
    return (externalTask, externalTaskService) -> {
      int score = externalTask.getVariable("score");
      externalTaskService.complete(externalTask);

      LOG.info("{}: The External Task {} has been granted with score {}!", workerId, externalTask.getId(), score);
    };
  }

  @ExternalTaskSubscription("requestRejecter")
  @Bean
  public ExternalTaskHandler requestRejecter() {
    return (externalTask, externalTaskService) -> {
      int score = externalTask.getVariable("score");
      externalTaskService.complete(externalTask);

      LOG.info("{}: The External Task {} has been rejected with score {}!", workerId, externalTask.getId(), score);
    };
  }

  @EventListener(SubscriptionInitializedEvent.class)
  public void catchSubscriptionInitEvent(SubscriptionInitializedEvent event) {

    SpringTopicSubscription topicSubscription = event.getSource();
    if (!topicSubscription.isAutoOpen()) {

      // open topic in case it is not opened already
      topicSubscription.open();

      LOG.info("Subscription with topic name '{}' has been opened!",
          topicSubscription.getTopicName());
    }
  }

}

the following class requires

camunda-bpm-spring-boot-starter-external-task-client