dill21yu opened a new issue, #17337:
URL: https://github.com/apache/dolphinscheduler/issues/17337

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and 
found no similar feature requirement.
   
   
   ### Description
   
   Currently, the HTTP Task plugin in DolphinScheduler has limitations in 
handling request parameters and response validation. This proposal suggests two 
key optimizations:
   
   1、Add support for form-data (x-www-form-urlencoded ) requests
   Currently, only raw JSON body is supported. Some APIs  require form-data.
   
   2、Add JSONPath-based response validation
   Allow users to validate HTTP responses using JSONPath expressions with 
success/failure patterns.
   
   Proposed Solution
   1. Form-Data Body Support
   Add a bodyType parameter with two options:
   kv: Parse parameters as form-data (key-value pairs).
   raw: Keep existing behavior (treat body as raw JSON string).
   
   Backend Handling:
   
   When bodyType=kv, convert parameters to application/x-www-form-urlencoded.
   When bodyType=raw, maintain current JSON processing.
   2. JSONPath Response Validation
   Add new validation fields:****
   <html>
   <body>
   <!--StartFragment-->
   Parameter | Required | Description
   -- | -- | --
   successJsonPath | Yes | JSONPath to extract value from response (e.g., 
$.status.code).
   successPatterns | Yes | Comma-separated success values (e.g., 200,SUCCESS). 
Regex NOT supported.
   failurePatterns | No | Comma-separated failure values (e.g., 500,FAIL).
   
   <!--EndFragment-->
   </body>
   </html>
   Validation Logic:
   
   Extract value via successJsonPath.
   1. First, check if the HTTP response status code is 200:
      - If status code ≠ 200 → Immediate task failure
      - If status code = 200 → Proceed to content validation
   
   2. For successful (200) responses:
      a. Extract value using successJsonPath
      b. Match extracted value against successPatterns:
         - If ANY match → Task succeeds
         - If NO match → Proceed to step 3
   
   3. Check against failurePatterns (if configured):
      - If ANY match → Task fails, and log response
      - If NO match → Task fails, and log response
   
   Technical Notes
   Dependencies:
   Use existing JSONPath library (already in DS dependencies): 
com.jayway.jsonpath:json-path.
   Backward Compatibility:
   No breaking changes; new parameters are optional.
   Security:
   Restrict successPatterns/failurePatterns to prevent regex injection (only 
allow A-Za-z0-9_-${}).
   Example UI :
   
![Image](https://github.com/user-attachments/assets/1cdd5261-3e5d-4d4d-bfab-594968a59789)
   
   
![Image](https://github.com/user-attachments/assets/9c0af098-0644-4aa4-8985-7016a4d143a6)
   
   ### Are you willing to submit a 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