Content-Length: 297338 | pFad | http://github.com/lowcoder-org/lowcoder/pull/1803/commits/1e0295f17ff23679a209ce332bebacf00328061f

A6 [Feat]: Add Import from cURL in Query Library by iamfaran · Pull Request #1803 · lowcoder-org/lowcoder · GitHub
Skip to content

[Feat]: Add Import from cURL in Query Library #1803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 24, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix body issue
  • Loading branch information
iamfaran committed Jun 23, 2025
commit 1e0295f17ff23679a209ce332bebacf00328061f
44 changes: 37 additions & 7 deletions client/packages/lowcoder/src/comps/queries/queryComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -761,22 +761,52 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {

// If this is a REST API created from cURL, pre-populate the HTTP query fields
if (compType === "restApi" && curlData) {
const headersArr = curlData.header
? Object.entries(curlData.header).map(([key, value]) => ({ key, value }))
// Normalize possible field names returned by different curl parsers
const rawHeaders: Record<string, any> | undefined =
curlData.header || curlData.headers;
const rawParams: Record<string, any> | undefined =
curlData.params || curlData.parameters || curlData.query;

// Convert headers & params objects to the key/value array expected by the UI controls
const headersArr = rawHeaders
? Object.entries(rawHeaders).map(([key, value]) => ({ key, value }))
: [{ key: "", value: "" }];
const paramsArr = curlData.params
? Object.entries(curlData.params).map(([key, value]) => ({ key, value }))

const paramsArr = rawParams
? Object.entries(rawParams).map(([key, value]) => ({ key, value }))
: [{ key: "", value: "" }];

// Detect request body – different parsers may expose it under various keys
const bodyContent: any =
curlData.body ?? curlData.data ?? curlData.postData ?? undefined;

// Determine body type – prefer the Content-Type header if present
let bodyType: string = "none";
if (bodyContent !== undefined && bodyContent !== "") {
const contentTypeHeader =
(rawHeaders && (rawHeaders["Content-Type"] || rawHeaders["content-type"])) ||
"";
if (contentTypeHeader) {
bodyType = contentTypeHeader;
} else if (typeof bodyContent === "object") {
bodyType = "application/json";
} else {
bodyType = "text/plain";
}
}

payload = {
...payload,
comp: {
httpMethod: curlData.method || "GET",
path: curlData.url || "",
path: curlData.url || curlData.path || "",
headers: headersArr,
params: paramsArr,
bodyType: curlData.body ? "application/json" : "none",
body: curlData.body ? JSON.stringify(curlData.body, null, 2) : "",
bodyType: bodyType,
body:
typeof bodyContent === "object"
? JSON.stringify(bodyContent, null, 2)
: bodyContent || "",
bodyFormData: [{ key: "", value: "", type: "text" }],
},
};
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/lowcoder-org/lowcoder/pull/1803/commits/1e0295f17ff23679a209ce332bebacf00328061f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy