cURL 명령줄을 사용한 POST XML 파일
XML 파일을 로컬 서버에 게시하려면 어떻게 해야 합니까?http://localhost:8080
명령 줄의 cURL을 사용할 수 있습니까?
어떤 명령을 사용해야 합니까?
해당 질문이 다른 허드슨 질문과 연결되어 있으면 해당 질문이 제공하는 명령을 사용합니다.명령줄에서 XML을 사용하는 방법:
$ curl -X POST -d '<run>...</run>' \
http://user:pass@myhost:myport/path/of/url
파일에서 읽으려면 약간의 변경이 필요합니다.
$ curl -X POST -d @myfilename http://user:pass@myhost:myport/path/of/url
맨페이지를 읽어보세요.-d 파라미터에 대한 추상적인 값을 따릅니다.
-d/--data
(HTTP) 사용자가 HTML 양식을 작성하고 제출 버튼을 누를 때 브라우저가 하는 것과 동일하게 POST 요청에 지정된 데이터를 HTTP 서버로 보냅니다.이렇게 하면 content-type application/x-www-form-urlencoded를 사용하여 curl이 데이터를 서버로 전달합니다.-F/--폼과 비교합니다.
-d/--data는 --data-limit과 동일합니다.순수하게 이진 데이터를 게시하려면 대신 --data-binary 옵션을 사용해야 합니다.양식 필드의 값을 URL 인코딩하려면 --data-urlencode를 사용할 수 있습니다.
이 옵션 중 하나라도 동일한 명령줄에서 두 번 이상 사용할 경우 지정된 데이터 조각이 구분 &- 기호와 함께 병합됩니다.따라서 '-d name=function -d skill=function'을 사용하면 'name=function&function=function'처럼 보이는 포스트 청크가 생성됩니다.
@ 문자로 데이터를 시작하는 경우 나머지는 데이터를 읽을 수 있는 파일 이름이어야 하며, stdin에서 데이터를 읽기 위해 curl을 사용하는 경우 -이어야 합니다.파일의 내용이 이미 URL로 인코딩되어 있어야 합니다.여러 파일을 지정할 수도 있습니다.따라서 'foobar'라는 이름의 파일에서 데이터를 게시하는 것은 --data @foobar로 수행됩니다.
맨페이지를 보면, 당신이 찾고 있는 드로이드들이 있다고 생각합니다.
-F/--form <name=content>
(HTTP) 이를 통해 curl은 사용자가 제출 버튼을 누른 채로 입력된 양식을 에뮬레이트할 수 있습니다.이로 인해 RFC2388에 따라 Content-Type multipart/form-data를 사용하여 데이터를 POST합니다.이를 통해 바이너리 파일 등을 업로드 할 수 있습니다.'content' 부분을 강제로 파일로 만들려면 파일 이름 앞에 @ 기호를 붙입니다.
예를 들어, 서버에 암호 파일을 전송하려면, 여기서 'password'는 /etc/passwd가 입력될 폼 필드의 이름입니다.
curl -F password=@/etc/passwd www.mypasswords.com
그래서 당신의 경우에는, 이건 마치
curl -F file=@/some/file/on/your/local/disk http://localhost:8080
--data with file 옵션을 사용할 수 있습니다.
이름이 soap_get.xml인 파일에 xml 콘텐츠를 쓰고 curl 명령을 사용하여 요청을 보냅니다.
curl -X POST --curl "Content-Type:text/xml;charset=UTF-8" --data @soap_get.xml your_url
1하면 Jenkins 1.494 파일을 사용하여 12 변수에 수 .curl
와 함께--form
매개변수:
curl --form name=myfileparam --form file=@/local/path/to/your/file.xml \
-Fjson='{"parameter": {"name": "myfileparam", "file": "file"}}' \
-Fsubmit=Build \
http://user:password@jenkinsserver/job/jobname/build
Jenkins라는 했습니다.myfileparam
.
컬 첫 번째 은 을 을 합니다 의 을 합니다 을 의 myfileparam
(은 일)라는 이름의 값은 로컬 파일 시스템에 있는 파일의 내용입니다./local/path/to/your/file.txt
.@
symbol prefix는 curl이 지정된 파일 이름 대신 로컬 파일을 보내도록 지시합니다.
두 은 첫폼합니다. 즉, 은 의 하는 합니다 을 와 JSON 을 합니다 하는 이름은 파일 매개 변수입니다.myfileparam
.
세 번째 줄이 양식의 빌드 단추를 활성화합니다.네 번째 줄은 접미사가 "/build"인 작업 URL입니다.
은 이 하면 이 됩니다 됩니다 이 을 반환합니다.0
. 성공하지 못한 경우 서비스의 오류 또는 예외가 콘솔에 인쇄됩니다.이 답변은 허드슨과 관련된 오래된 블로그 게시물에서 가져온 것으로, 제 자신의 필요를 위해 해체하고 다시 작업한 것입니다.
Windows에서 curl 명령줄을 사용하여 XML을 Windows에 게시하는 방법은 다음과 같습니다.batch/.cmd 파일을 사용하는 것이 좋습니다.
curl -i -X POST -H "Content-Type: text/xml" -d ^
"^<?xml version=\"1.0\" encoding=\"UTF-8\" ?^> ^
^<Transaction^> ^
^<SomeParam1^>Some-Param-01^</SomeParam1^> ^
^<Password^>SomePassW0rd^</Password^> ^
^<Transaction_Type^>00^</Transaction_Type^> ^
^<CardHoldersName^>John Smith^</CardHoldersName^> ^
^<DollarAmount^>9.97^</DollarAmount^> ^
^<Card_Number^>4111111111111111^</Card_Number^> ^
^<Expiry_Date^>1118^</Expiry_Date^> ^
^<VerificationStr2^>123^</VerificationStr2^> ^
^<CVD_Presence_Ind^>1^</CVD_Presence_Ind^> ^
^<Reference_No^>Some Reference Text^</Reference_No^> ^
^<Client_Email^>john@smith.com^</Client_Email^> ^
^<Client_IP^>123.4.56.7^</Client_IP^> ^
^<Tax1Amount^>^</Tax1Amount^> ^
^<Tax2Amount^>^</Tax2Amount^> ^
^</Transaction^> ^
" "http://localhost:8080"
다음 명령을 사용할 수 있습니다.
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'Authorization: <<Removed>>' -F file=@"/home/xxx/Desktop/customers.json" 'API_SERVER_URL' -k
헤더가 여러 개인 경우 다음을 사용할 수 있습니다.
curl -X POST --header "Content-Type:application/json" --header "X-Auth:AuthKey" --data @hello.json Your_url
Windows에서 컬을 사용하는 경우:
curl -H "Content-Type: application/xml" -d "<?xml version="""1.0""" encoding="""UTF-8""" standalone="""yes"""?><message><sender>Me</sender><content>Hello!</content></message>" http://localhost:8080/webapp/rest/hello
Powershell + Curl + Zimbra SOAP API
${my_xml} = @"
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">
<soapenv:Body>
<GetFolderRequest xmlns=\"urn:zimbraMail\">
<folder>
<path>Folder Name</path>
</folder>
</GetFolderRequest>
</soapenv:Body>
</soapenv:Envelope>
"@
${my_curl} = "c:\curl.exe"
${cookie} = "c:\cookie.txt"
${zimbra_soap_url} = "https://zimbra:7071/service/admin/soap"
${curl_getfolder_args} = "-b", "${cookie}",
"--header", "Content-Type: text/xml;charset=UTF-8",
"--silent",
"--data-raw", "${my_xml}",
"--url", "${zimbra_soap_url}"
[xml]${my_response} = & ${my_curl} ${curl_getfolder_args}
${my_response}.Envelope.Body.GetFolderResponse.folder.id
언급URL : https://stackoverflow.com/questions/3007253/post-xml-file-using-curl-command-line
'programing' 카테고리의 다른 글
Spring 3 / Thymeleaf에서 매개변수를 사용하여 지역화 메시지를 표시하는 방법 (0) | 2023.09.10 |
---|---|
대화를 위한 데이터베이스 스키마: 개인 및 그룹 (0) | 2023.09.10 |
UI뷰 쉐이크 애니메이션 (0) | 2023.09.10 |
안드로이드란 무엇입니까?R.layout.simple_list_item_1"? (0) | 2023.09.10 |
XElement 또는 LINQ와 함께 XPath를 사용하는 방법은 무엇입니까? (0) | 2023.09.10 |