| Line 10... |
Line 10... |
| 10 |
import java.io.BufferedReader;
|
10 |
import java.io.BufferedReader;
|
| 11 |
import java.io.File;
|
11 |
import java.io.File;
|
| 12 |
import java.io.IOException;
|
12 |
import java.io.IOException;
|
| 13 |
import java.io.InputStreamReader;
|
13 |
import java.io.InputStreamReader;
|
| 14 |
import java.io.UnsupportedEncodingException;
|
14 |
import java.io.UnsupportedEncodingException;
|
| - |
|
15 |
import java.nio.charset.Charset;
|
| 15 |
import java.util.ArrayList;
|
16 |
import java.util.ArrayList;
|
| 16 |
import java.util.HashMap;
|
17 |
import java.util.HashMap;
|
| 17 |
import java.util.List;
|
18 |
import java.util.List;
|
| 18 |
import java.util.Map;
|
19 |
import java.util.Map;
|
| 19 |
import javax.mail.MessagingException;
|
20 |
import javax.mail.MessagingException;
|
| - |
|
21 |
|
| - |
|
22 |
import org.apache.commons.codec.binary.Base64;
|
| - |
|
23 |
import org.apache.http.HttpHeaders;
|
| 20 |
import org.apache.http.HttpResponse;
|
24 |
import org.apache.http.HttpResponse;
|
| 21 |
import org.apache.http.auth.AuthScope;
|
25 |
import org.apache.http.auth.AuthScope;
|
| 22 |
import org.apache.http.auth.UsernamePasswordCredentials;
|
26 |
import org.apache.http.auth.UsernamePasswordCredentials;
|
| 23 |
import org.apache.http.client.ClientProtocolException;
|
27 |
import org.apache.http.client.ClientProtocolException;
|
| 24 |
import org.apache.http.client.methods.HttpPost;
|
28 |
import org.apache.http.client.methods.HttpPost;
|
| Line 109... |
Line 113... |
| 109 |
|
113 |
|
| 110 |
}
|
114 |
}
|
| 111 |
|
115 |
|
| 112 |
public static void main(String[] args) throws ClientProtocolException, TException{
|
116 |
public static void main(String[] args) throws ClientProtocolException, TException{
|
| 113 |
DefaultHttpClient httpclient = new DefaultHttpClient();
|
117 |
DefaultHttpClient httpclient = new DefaultHttpClient();
|
| 114 |
httpclient = (DefaultHttpClient) WebClientWrapper.wrapClient(httpclient);
|
118 |
//httpclient = (DefaultHttpClient) WebClientWrapper.wrapClient(httpclient);
|
| 115 |
//httpclient.getCredentialsProvider().setCredentials(
|
119 |
//httpclient.getCredentialsProvider().setCredentials(
|
| 116 |
// new AuthScope("sandbox-api.flipkart.net", 443),
|
120 |
// new AuthScope("sandbox-api.flipkart.net", 443),
|
| 117 |
// new UsernamePasswordCredentials("og3yg5994bxbxxc1", "8a137068-417c-4e4f-ae95-9295ab938d88"));/// Test Server Access Keys
|
121 |
// new UsernamePasswordCredentials("og3yg5994bxbxxc1", "8a137068-417c-4e4f-ae95-9295ab938d88"));/// Test Server Access Keys
|
| 118 |
httpclient.getCredentialsProvider().setCredentials(
|
122 |
//httpclient.getCredentialsProvider().setCredentials(
|
| 119 |
new AuthScope("api.flipkart.net", 443),
|
123 |
// new AuthScope("api.flipkart.net", 443),
|
| 120 |
new UsernamePasswordCredentials("m2z93iskuj81qiid","0c7ab6a5-98c0-4cdc-8be3-72c591e0add4")); //Prod Server Access Keys
|
124 |
// new UsernamePasswordCredentials("m2z93iskuj81qiid","0c7ab6a5-98c0-4cdc-8be3-72c591e0add4")); //Prod Server Access Keys
|
| - |
|
125 |
|
| 121 |
HttpPost httppost = new HttpPost("https://api.flipkart.net/sellers/skus/listings/bulk"); // PROD
|
126 |
HttpPost httppost = new HttpPost("https://api.flipkart.net/sellers/skus/listings/bulk"); // PROD
|
| - |
|
127 |
|
| - |
|
128 |
String auth = "m2z93iskuj81qiid"+":"+"0c7ab6a5-98c0-4cdc-8be3-72c591e0add4";
|
| - |
|
129 |
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII")));
|
| - |
|
130 |
String authHeader = "Basic " + new String(encodedAuth);
|
| - |
|
131 |
httppost.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
|
| 122 |
//HttpPost httppost = new HttpPost("https://sandbox-api.flipkart.net/sellers/skus/listings/bulk"); // TEST
|
132 |
//HttpPost httppost = new HttpPost("https://sandbox-api.flipkart.net/sellers/skus/listings/bulk"); // TEST
|
| 123 |
StringBuffer jsonRequest = new StringBuffer();
|
133 |
StringBuffer jsonRequest = new StringBuffer();
|
| 124 |
StringBuffer jsonStart = new StringBuffer();
|
134 |
StringBuffer jsonStart = new StringBuffer();
|
| 125 |
jsonStart = jsonStart.append("{\"listings\":[");
|
135 |
jsonStart = jsonStart.append("{\"listings\":[");
|
| 126 |
StringBuffer jsonEnd = new StringBuffer();
|
136 |
StringBuffer jsonEnd = new StringBuffer();
|