| Line 27... |
Line 27... |
| 27 |
import java.io.BufferedReader;
|
27 |
import java.io.BufferedReader;
|
| 28 |
import java.io.File;
|
28 |
import java.io.File;
|
| 29 |
import java.io.IOException;
|
29 |
import java.io.IOException;
|
| 30 |
import java.io.InputStreamReader;
|
30 |
import java.io.InputStreamReader;
|
| 31 |
import java.io.UnsupportedEncodingException;
|
31 |
import java.io.UnsupportedEncodingException;
|
| - |
|
32 |
import java.nio.charset.Charset;
|
| 32 |
import java.util.ArrayList;
|
33 |
import java.util.ArrayList;
|
| 33 |
import java.util.HashMap;
|
34 |
import java.util.HashMap;
|
| 34 |
import java.util.List;
|
35 |
import java.util.List;
|
| 35 |
import java.util.Map;
|
36 |
import java.util.Map;
|
| 36 |
import java.util.Map.Entry;
|
37 |
import java.util.Map.Entry;
|
| 37 |
|
38 |
|
| 38 |
import javax.mail.MessagingException;
|
39 |
import javax.mail.MessagingException;
|
| 39 |
|
40 |
|
| - |
|
41 |
import org.apache.http.HttpHeaders;
|
| 40 |
import org.apache.http.HttpResponse;
|
42 |
import org.apache.http.HttpResponse;
|
| 41 |
import org.apache.http.NameValuePair;
|
43 |
import org.apache.http.NameValuePair;
|
| 42 |
import org.apache.http.auth.AuthScope;
|
44 |
import org.apache.http.auth.AuthScope;
|
| 43 |
import org.apache.http.auth.UsernamePasswordCredentials;
|
45 |
import org.apache.http.auth.UsernamePasswordCredentials;
|
| 44 |
import org.apache.http.client.ClientProtocolException;
|
46 |
import org.apache.http.client.ClientProtocolException;
|
| Line 50... |
Line 52... |
| 50 |
import org.apache.http.impl.client.DefaultHttpClient;
|
52 |
import org.apache.http.impl.client.DefaultHttpClient;
|
| 51 |
import org.apache.http.message.BasicNameValuePair;
|
53 |
import org.apache.http.message.BasicNameValuePair;
|
| 52 |
import org.apache.thrift.TException;
|
54 |
import org.apache.thrift.TException;
|
| 53 |
import org.apache.thrift.transport.TTransportException;
|
55 |
import org.apache.thrift.transport.TTransportException;
|
| 54 |
|
56 |
|
| - |
|
57 |
import com.google.appengine.repackaged.org.apache.commons.codec.binary.Base64;
|
| 55 |
import com.google.gson.Gson;
|
58 |
import com.google.gson.Gson;
|
| 56 |
|
59 |
|
| 57 |
|
60 |
|
| 58 |
|
61 |
|
| 59 |
public class CreateSubmitFlipkartInventoryFeed {
|
62 |
public class CreateSubmitFlipkartInventoryFeed {
|
| Line 167... |
Line 170... |
| 167 |
// new AuthScope("sandbox-api.flipkart.net", 443),
|
170 |
// new AuthScope("sandbox-api.flipkart.net", 443),
|
| 168 |
// new UsernamePasswordCredentials("og3yg5994bxbxxc1", "8a137068-417c-4e4f-ae95-9295ab938d88"));/// Test Server Access Keys
|
171 |
// new UsernamePasswordCredentials("og3yg5994bxbxxc1", "8a137068-417c-4e4f-ae95-9295ab938d88"));/// Test Server Access Keys
|
| 169 |
//httpclient.getCredentialsProvider().setCredentials(
|
172 |
//httpclient.getCredentialsProvider().setCredentials(
|
| 170 |
// new AuthScope("api.flipkart.net", 443),
|
173 |
// new AuthScope("api.flipkart.net", 443),
|
| 171 |
// new UsernamePasswordCredentials("m2z93iskuj81qiid","0c7ab6a5-98c0-4cdc-8be3-72c591e0add4")); //Prod Server Access Keys
|
174 |
// new UsernamePasswordCredentials("m2z93iskuj81qiid","0c7ab6a5-98c0-4cdc-8be3-72c591e0add4")); //Prod Server Access Keys
|
| - |
|
175 |
|
| 172 |
HttpPost httppost = new HttpPost("https://api.flipkart.net/sellers/skus/listings/bulk"); // PROD
|
176 |
HttpPost httppost = new HttpPost("https://api.flipkart.net/sellers/skus/listings/bulk"); // PROD
|
| - |
|
177 |
|
| 173 |
httppost.addHeader("m2z93iskuj81qiid","0c7ab6a5-98c0-4cdc-8be3-72c591e0add4");
|
178 |
String auth = "m2z93iskuj81qiid"+":"+"0c7ab6a5-98c0-4cdc-8be3-72c591e0add4";
|
| - |
|
179 |
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII")));
|
| - |
|
180 |
String authHeader = "Basic " + new String(encodedAuth);
|
| - |
|
181 |
httppost.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
|
| 174 |
//HttpPost httppost = new HttpPost("https://sandbox-api.flipkart.net/sellers/skus/listings/bulk"); // TEST
|
182 |
//HttpPost httppost = new HttpPost("https://sandbox-api.flipkart.net/sellers/skus/listings/bulk"); // TEST
|
| 175 |
StringBuffer jsonRequest = new StringBuffer();
|
183 |
StringBuffer jsonRequest = new StringBuffer();
|
| 176 |
StringBuffer jsonStart = new StringBuffer();
|
184 |
StringBuffer jsonStart = new StringBuffer();
|
| 177 |
jsonStart = jsonStart.append("{\"listings\":[");
|
185 |
jsonStart = jsonStart.append("{\"listings\":[");
|
| 178 |
StringBuffer jsonEnd = new StringBuffer();
|
186 |
StringBuffer jsonEnd = new StringBuffer();
|