Back

c# code

using(System.Net.WebClient wc = new WebClient())
        {
        // sandbox url
        string url = "https://api-partner.pcbway.com/api/Pcb/PcbQuotation";
        // your aapikey 
        wc.Headers["api-key"] = "your apikey";
            
        //json format
        wc.Headers["Content-Type"] = "application/json";
//pcb parameters (autogeneration json string according to your pcb parameters ) // var postData = Newtonsoft.Json.JsonConvert.SerializeObject(new //{ // width = 100, // length = 100, // layer = 2 //.......... //}); var postData = "{\"Length\":100.0,\"width\":100.0,\"layers\":2,\"Qty\":10,\"Thickness\":1.6,\"Material\":\"FR-4\",\"DesignInPanel\":1,\"MinTrackSpacing\":\"6/6mil\",\"MinHoleSize\":0.3,\"SolderMask\":\"Green\",\"Silkscreen\":\"White\",\"SurfaceFinish\":\"HASL with lead\",\"ViaProcess\":\"Tenting vias\",\"FinishedCopper\":\"1 oz Cu\",\"returnPriceMatirx\":false,\"pcbFileUrl\":\"http://www.website.com/rar.zip\",\"PcbFileName\":\"pcbfile.rar\",buildDays:1,\"note\":\"test note\"}";
//response json string var responseJson = wc.UploadString(url, postData); Console.WriteLine(responseJson);
}

php code

<?php
// Your apikey 
$apiky = '';
//sandbox url
$url= "http://api-partner.pcbway.com/api/Pcb/PcbQuotation";
//pcb parameters (autogeneration json string according to your pcb parameters )
//$data = array(
//    'width'  => 100,
//	'length' =>100,
//	 'layer' =>2
//    ........
//);
//$json = json_encode($data);
$postData = "{\"Length\":100.0,\"width\":100.0,\"layers\":2,\"Qty\":10,\"Thickness\":1.6,\"Material\":\"FR-4\",\"DesignInPanel\":1,\"MinTrackSpacing\":\"6/6mil\",\"MinHoleSize\":0.3,\"SolderMask\":\"Green\",\"Silkscreen\":\"White\",\"SurfaceFinish\":\"HASL with lead\",\"ViaProcess\":\"Tenting vias\",\"FinishedCopper\":\"1 oz Cu\",\"returnPriceMatirx\":false,\"pcbFileUrl\":\"http://www.website.com/rar.zip\",\"PcbFileName\":\"pcbfile.rar\",buildDays:1,\"note\":\"test note\"}";
$ch = curl_init($url);
curl_setopt_array($ch, array(
            CURLOPT_POST => TRUE,
            CURLOPT_HTTPHEADER => array(
            'api-key: '.$apiky,
            'Content-Type: application/json'
            ),
            CURLOPT_POSTFIELDS => $postData
));
//curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
//$responsJsoneData = json_decode($response, TRUE);
curl_close($ch);
?>

java code (use apache httpcomponents )

        String url = "https://api-partner.pcbway.com/api/Pcb/PcbQuotation";// test 
																				
		String apiKey = ""
		
               //pcb parameters (autogeneration json string according to your pcb parameters )
            
		//  Gson gson = new Gson();	// google gson 
		// PcbModel pcb=new PcbModel();
		// pcb.Layers=100;
		// pcb.Width=100;
		// pcb.Layers=2;....
		// String testPostData = gson.toJson(pcb);
String testPostData= "{\"Length\":100.0,\"width\":100.0,\"layers\":2,\"Qty\":10,\"Thickness\":1.6,\"Material\":\"FR-4\",\"DesignInPanel\":1,\"MinTrackSpacing\":\"6/6mil\",\"MinHoleSize\":0.3,\"SolderMask\":\"Green\",\"Silkscreen\":\"White\",\"SurfaceFinish\":\"HASL with lead\",\"ViaProcess\":\"Tenting vias\",\"FinishedCopper\":\"1 oz Cu\",\"returnPriceMatirx\":false,\"pcbFileUrl\":\"http://www.website.com/rar.zip\",\"PcbFileName\":\"pcbfile.rar\",buildDays:1,\"note\":\"test note\"}";
CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(url); httpPost.addHeader("api-key", apiKey); httpPost.addHeader("Content-Type", "application/json"); StringEntity requestEntity = new StringEntity(testPostData); httpPost.setEntity(requestEntity); CloseableHttpResponse response = httpclient.execute(httpPost); HttpEntity entity = response.getEntity(); String jsonString = EntityUtils.toString(entity); EntityUtils.consume(entity);      System.out.println(jsonString); response.close(); // using a simpler, albeit less flexible, fluent API. Content responseContent = Request.Post(url) .addHeader("api-key", apiKey) .bodyString(testPostData, ContentType.APPLICATION_JSON).execute() .returnContent(); System.out.println(responseContent.asString());