---
sourceDocument: Xanadu 애플리케이션과의 통합 생성
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/xanadu/integrate-applications

 Release :

    - xanadu

ft:locale :

    - ko-KR

ft:publication_title :

    - Xanadu 애플리케이션과의 통합 생성

ft:clusterId :

    - crint

bundleId :

    - crint

workflow :

    - Creator


---

# CSV 파일 게시 - Perl 및 Java 예제

# CSV 파일 게시 - Perl 및 Java 예제 {#ariaid-title1}

* 릴리스 버전: Xanadu
* 
* 업데이트 날짜 2024년 08월 01일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 4분

Perl을 사용하여 기본 인증 자격 증명으로 CSV 파일을 게시하고 Java Apache HttpClient 클래스를 사용하여 기본 인증 자격 증명으로 CSV 파일을 게시하는 예입니다.
자세한 내용은 [CSV 또는 Excel 파일을 임포트 세트에 직접 게시](https://servicenow-prod.fluidtopics.net/BMaO~sNjMnRkadwZ23XiLA "관리자는 CSV 또는 Excel 파일을 인스턴스에 직접 게시할 수 있습니다.") 문서를 참조하십시오.

## Perl 예제 {#r_PerlExample__section_rpf_tsw_m1b}

    # file: uploadafile.pl
    # call me like this:
    # uploadafile.pl --url="https://instance.service-now.com/sys_import.do?sysparm_import_set_tablename=dloo_test&sysparm_transform_after_load=true" 
    # --uploadfile=/Users/davidloo/Desktop/test_files/test_users.csv
    #
    # the "sysparm_transform_after_load=true" parameter instructs the import set to transform immediately after loading
    #
    use strict;
    use LWP::UserAgent;
    use HTTP::Request::Common;
    use Getopt::Long;
    use File::Basename;
     
    my ( $o_url, $o_fqn );
    GetOptions(
        "url=s"        => \$o_url,
        "uploadfile=s" => \$o_fqn,
    );
     
    # mandatory arguments: url
    &usage unless ( $o_url && $o_fqn );
     
    my $url   = $o_url;
    my $fname = $o_fqn;
     
    # put timeouts, proxy etc into the useragent if needed
    my $ua  = LWP::UserAgent->new();
     
    # setup basic authentication credentials
    $ua->credentials(
      'demo.service-now.com:443',
      'Service-now',
      'admin' => 'admin'
    );
     
    my $req = POST $url, Content_Type => 'form-data',
            Content      => [
                    submit => 1,
                    upfile =>  [ $fname ]
            ];
    my $response = $ua->request($req);
     
     
     
    if ($response->is_success()) {
        print "OK: ", $response->content;
    } else {
        print $response->as_string;
    }
     
    exit;
     
    sub usage {
            printf "usage: %s --url=%s --uploadfile=%s\\n",
                    basename($0),'https://....','c:/data/test.csv';
            exit
    }

## Java 예제 {#r_PerlExample__section_fbp_5sw_m1b}

주:  
Apache HttpClient는 단일 트랜잭션에서 가져올 수 있는 데이터의 양을 제한할 수 있습니다. 이 예제는 시작점으로 사용하기 위한 것이며 프로덕션에서 사용해서는 안 됩니다.

    HttpClient httpclient = new HttpClient();
    PostMethod post = new PostMethod("https://instance-name.service-now.com/sys_import.do?sysparm_import_set_tablename=u_test_upload&sysparm_transform_after_load=true");
     
    try {
      Credentials defaultcreds = new UsernamePasswordCredentials("admin", "admin");
      httpclient.getState().setCredentials(AuthScope.ANY, defaultcreds); // Prepare HTTP post
      httpclient.getParams().setAuthenticationPreemptive(true);
     
      File targetFile = new File("/Users/davidloo/Desktop/test_files/nodeinfo2736820198834983863.csv");
      Part[] parts = { new FilePart(targetFile.getName(), targetFile) };
     
      post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
     
      int result = httpclient.executeMethod(post);
     
      // Display status code
      System.out.println("Response status code: " + result);
     
      // Display response
      System.out.println("Response body: "+post.getResponseBodyAsString());
    } catch(Exception e) {
      System.err.println(e.getMessage());
    } finally {
      // Release current connection to the connection pool
      // once you are done
      post.releaseConnection();
    }


