"use strict";(self.webpackChunkvalidator_frontend=self.webpackChunkvalidator_frontend||[]).push([[207],{7480:function(e,t,n){n.r(t),n.d(t,{assets:function(){return l},contentTitle:function(){return o},default:function(){return c},frontMatter:function(){return r},metadata:function(){return s},toc:function(){return p}});var a=n(7462),i=(n(7294),n(3905));const r={sidebar_position:2},o="API Usage",s={unversionedId:"api",id:"api",title:"API Usage",description:"The validation service listens to POST-requests to any server uri. You need to supply the xml/object to validate in",source:"@site/docs/api.md",sourceDirName:".",slug:"/api",permalink:"/docs/api",draft:!1,editUrl:"https://github.com/itplr-kosit/validator/server/ui/docs/api.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2},sidebar:"tutorialSidebar",previous:{title:"Configurations",permalink:"/docs/configurations"},next:{title:"Changelog",permalink:"/docs/changelog"}},l={},p=[],u={toc:p};function c(e){let{components:t,...n}=e;return(0,i.kt)("wrapper",(0,a.Z)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,i.kt)("h1",{id:"api-usage"},"API Usage"),(0,i.kt)("p",null,"The validation service listens to ",(0,i.kt)("inlineCode",{parentName:"p"},"POST"),"-requests to any server uri. You need to supply the xml/object to validate in\nthe post body.\nThe service expects a single plain input in the post body, e.g. ",(0,i.kt)("inlineCode",{parentName:"p"},"multipart/form-data")," is not supported."),(0,i.kt)("p",null,"Examples:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"cURL"))),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-shell",metastring:"script",script:!0},"curl --location --request POST 'http://localhost:8080' \\\n--header 'Content-Type: application/xml' \\\n--data-binary '@/target.xml'\n")),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"java")," (Apache HttpClient)")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-java"},'HttpClient httpClient=HttpClientBuilder.create().build();\n HttpPost postRequest=new HttpPost("http://localhost:8080/");\n FileEntity entity=new FileEntity(Paths.get("some.xml").toFile(),ContentType.APPLICATION_XML);\n postRequest.setEntity(entity);\n HttpResponse response=httpClient.execute(postRequest);\n System.out.println(IOUtils.toString(response.getEntity().getContent()));\n')),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"javascript"))),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-javascript"},'var myHeaders = new Headers();\nmyHeaders.append("Content-Type", "application/xml");\n\nvar file = "";\n\nvar requestOptions = {\n method: \'POST\',\n headers: myHeaders,\n body: file,\n redirect: \'follow\'\n};\n\nfetch("http://localhost:8080", requestOptions)\n .then(response => response.text())\n .then(result => console.log(result))\n .catch(error => console.log(\'error\', error));\n')))}c.isMDXComponent=!0}}]);