hx23840 opened a new issue, #3628:
URL: https://github.com/apache/incubator-seatunnel/issues/3628

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   When i try http connector, in config, body is not required, but it error 
with not set body; set json_field,the jsonpath init error;parseMap parse json 
data error
   
   ### SeaTunnel Version
   
   dev
   
   ### SeaTunnel Config
   
   ```conf
   env {
     # You can set flink configuration here
     execution.parallelism = 1
     job.mode = "BATCH"
     #execution.checkpoint.interval = 10000
     #execution.checkpoint.data-uri = "hdfs://localhost:9000/checkpoint"
   }
   
   source {
     Http {
       url = "http://192.168.50.58:8099/api/test";
       method = "POST"
       format = "json"
       json_field = {
         id = "$.results.items[*].id"
         name = "$.results.items[*].name"
         title = "$.results.items[*].title"
         url = "$.results.items[*].url"
         publish_time = "$.results.items[*].publish_time"
         score = "$.results.items[*].score"
       }
   
       schema = {
         fields {
           id = string
           name = string
           title = string
           url = string
           publish_time = string
           score = float
         }
       }
     }
   }
   
   transform {
   
   }
   
   sink {
     console {
   
     }
   }
   ```
   
   
   ### Running Command
   
   ```shell
   ./bin/seatunnel.sh \
   --config ./config/seatunnel.streaming.conf.template -e local
   ```
   
   
   ### Error Exception
   
   ```log
   2022-12-02 12:14:05,415 ERROR 
org.apache.seatunnel.connectors.seatunnel.http.source.HttpSourceReader - Index 
1 out of bounds for length 1
   java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
        at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) 
~[?:?]
        at 
jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) 
~[?:?]
        at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248) 
~[?:?]
        at java.util.Objects.checkIndex(Objects.java:372) ~[?:?]
        at java.util.ArrayList.get(ArrayList.java:459) ~[?:?]
        at 
org.apache.seatunnel.connectors.seatunnel.http.source.HttpSourceReader.parseToMap(HttpSourceReader.java:120)
 ~[classes/:?]
        at 
org.apache.seatunnel.connectors.seatunnel.http.source.HttpSourceReader.pollNext(HttpSourceReader.java:93)
 [classes/:?]
        at 
org.apache.seatunnel.engine.server.task.flow.SourceFlowLifeCycle.collect(SourceFlowLifeCycle.java:113)
 [classes/:?]
        at 
org.apache.seatunnel.engine.server.task.SourceSeaTunnelTask.collect(SourceSeaTunnelTask.java:68)
 [classes/:?]
        at 
org.apache.seatunnel.engine.server.task.SeaTunnelTask.stateProcess(SeaTunnelTask.java:150)
 [classes/:?]
        at 
org.apache.seatunnel.engine.server.task.SourceSeaTunnelTask.call(SourceSeaTunnelTask.java:74)
 [classes/:?]
        at 
org.apache.seatunnel.engine.server.TaskExecutionService$BlockingWorker.run(TaskExecutionService.java:286)
 [classes/:?]
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) 
[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java) [?:?]
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 
[?:?]
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 
[?:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]
   
   
   
   2022-12-02 12:11:17,444 ERROR 
org.apache.seatunnel.connectors.seatunnel.http.source.HttpSourceReader - Source 
string may not be null
   java.lang.IllegalArgumentException: Source string may not be null
        at org.apache.http.util.Args.notNull(Args.java:54) 
~[httpcore-4.4.4.jar:4.4.4]
        at org.apache.http.entity.StringEntity.<init>(StringEntity.java:67) 
~[httpcore-4.4.4.jar:4.4.4]
        at 
org.apache.seatunnel.connectors.seatunnel.http.client.HttpClientProvider.addBody(HttpClientProvider.java:385)
 ~[classes/:?]
        at 
org.apache.seatunnel.connectors.seatunnel.http.client.HttpClientProvider.doPost(HttpClientProvider.java:266)
 ~[classes/:?]
        at 
org.apache.seatunnel.connectors.seatunnel.http.client.HttpClientProvider.execute(HttpClientProvider.java:107)
 ~[classes/:?]
        at 
org.apache.seatunnel.connectors.seatunnel.http.source.HttpSourceReader.pollNext(HttpSourceReader.java:84)
 [classes/:?]
        at 
org.apache.seatunnel.engine.server.task.flow.SourceFlowLifeCycle.collect(SourceFlowLifeCycle.java:113)
 [classes/:?]
        at 
org.apache.seatunnel.engine.server.task.SourceSeaTunnelTask.collect(SourceSeaTunnelTask.java:68)
 [classes/:?]
        at 
org.apache.seatunnel.engine.server.task.SeaTunnelTask.stateProcess(SeaTunnelTask.java:150)
 [classes/:?]
        at 
org.apache.seatunnel.engine.server.task.SourceSeaTunnelTask.call(SourceSeaTunnelTask.java:74)
 [classes/:?]
        at 
org.apache.seatunnel.engine.server.TaskExecutionService$BlockingWorker.run(TaskExecutionService.java:286)
 [classes/:?]
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) 
[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java) [?:?]
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 
[?:?]
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 
[?:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]
   ```
   
   
   ### Flink or Spark Version
   
   _No response_
   
   ### Java or Scala Version
   
   _No response_
   
   ### Screenshots
   
   * body null error
   ![Screenshot from 2022-12-02 
12-12-45](https://user-images.githubusercontent.com/42536066/205216051-a19c9c46-294a-4427-b814-2f920546d598.png)
   
   * init jsonpath error
   ![Screenshot from 2022-12-02 
12-14-32](https://user-images.githubusercontent.com/42536066/205216074-af62f568-654b-4054-92c3-82db2cbe7211.png)
   
   * parse data error
   ![Screenshot from 2022-12-02 
12-17-34](https://user-images.githubusercontent.com/42536066/205216095-cbfd110f-b48f-49de-95f0-c0fc976571ad.png)
   
   * fix data 
   ![Screenshot from 2022-12-02 
12-19-20](https://user-images.githubusercontent.com/42536066/205216114-c09f7f51-a60b-41f9-82be-b468db27ae5d.png)
   
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to