摘要:需要?jiǎng)?chuàng)建的銷售訂單的明細(xì)通過硬編碼指定比如銷售訂單的描述為執(zhí)行之后,看到,說明創(chuàng)建成功到上能看到成功創(chuàng)建的銷售訂單實(shí)現(xiàn)代碼要獲取更多的原創(chuàng)文章,請(qǐng)關(guān)注公眾號(hào)汪子熙
需要?jiǎng)?chuàng)建的銷售訂單的明細(xì)通過硬編碼指定:
比如銷售訂單的描述為Jerry Test 2019-1-23 16:05PM
執(zhí)行之后,看到Status Code 201,說明創(chuàng)建成功:
到UI上能看到成功創(chuàng)建的銷售訂單:
實(shí)現(xiàn)代碼:
package odata; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URI; import org.apache.http.HttpEntity; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; public class SimpleOrderCreator { private final String SERVICEURL = "https://my5000jerry.c4c.saphybriscloud.cn/sap/c4c/odata/cust/v1/zjerrysalesorder/CustomerQuoteCollection"; HttpClient m_httpClient; private HttpClient getHttpClient() { if (this.m_httpClient == null) { this.m_httpClient = HttpClientBuilder.create().build(); } return this.m_httpClient; } private String getCSRFToken(){ final HttpGet get = new HttpGet(SERVICEURL); get.setHeader("Authorization", "Basic 0FOR0pFUlJZMTpTYXB0ZXN0MQ=="); get.setHeader("x-csrf-token", "fetch"); HttpHost proxy = new HttpHost("proxy.sha.sap.corp", 8080, "http"); RequestConfig config = RequestConfig.custom().setProxy(proxy).build(); get.setConfig(config); HttpResponse response; String token = null; try { response = getHttpClient().execute(get); /*Header[] header = response.getAllHeaders(); for( int i =0; i < header.length; i++){ System.out.println("Header: " + header[i].getValue()); }*/ token = response.getFirstHeader("x-csrf-token").getValue(); System.out.println("token: " + token); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException | UnsupportedOperationException e) { e.printStackTrace(); } return token; } private void createSO(String token,String body) { final HttpPost post = new HttpPost( URI.create(SERVICEURL)); post.setHeader("Authorization", "Basic 0FOR0pFUlJZMTpTYXB0ZXN0MQ=="); post.setHeader("Content-Type", "application/json"); post.setHeader("X-CSRF-Token", token); HttpEntity entity = null; try { entity = new StringEntity(body); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } post.setEntity(entity); HttpResponse response = null; try { response = getHttpClient().execute(post); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Response statusCode for Batch => " + response.getStatusLine().getStatusCode()); } public static void main(String[] args) { SimpleOrderCreator tool = new SimpleOrderCreator(); String token = tool.getCSRFToken(); String body = "{" + ""Name": "Jerry Test 2019-1-23 16:05PM"," + ""TypeCode": "2059"," + ""BuyerID":"ee"," + ""PartyID":"60102", " + ""CustomerQuoteText":[{" + ""Text": "test comment by Jerry Wang", " + ""TypeCode": "10024"" + "}]," + ""CustomerQuoteItem":[{ " + ""ProductID": "1042416"" + "}]," + ""CustomerQuoteItemProposal":[{" + ""ProductUUID": "00163E72-09C6-1EE8-BBDC-AC5F0CB0D795"," + ""Quantity": "1"," + ""unitCode": "EA"" + "}]" + "}"; tool.createSO(token, body); } }
要獲取更多Jerry的原創(chuàng)文章,請(qǐng)關(guān)注公眾號(hào)"汪子熙":
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/101482.html
摘要:機(jī)器學(xué)習(xí)在客戶管理場(chǎng)景中的應(yīng)用使用機(jī)器學(xué)習(xí)進(jìn)行客戶管理,我們可以得到客戶度全方位的視圖。可以看到機(jī)器學(xué)習(xí)給為和這兩個(gè)產(chǎn)品計(jì)算的相關(guān)分?jǐn)?shù)是和。關(guān)于機(jī)器學(xué)習(xí)在中的更多應(yīng)用,請(qǐng)參考幫助文檔。 關(guān)于機(jī)器學(xué)習(xí)這個(gè)話題,我相信我這個(gè)公眾號(hào)1500多位關(guān)注者里,一定有很多朋友的水平比Jerry高得多。如果您看過我以前兩篇文章,您就會(huì)發(fā)現(xiàn),我對(duì)機(jī)器學(xué)習(xí)僅僅停留在會(huì)使用API的層面上。 使用Java程...
摘要:小的時(shí)候,聽過牛頓這樣謙虛的一句話如果說我看得比別人更遠(yuǎn)些,那是因?yàn)槲艺驹诰奕说募绨蛏稀?。發(fā)布一個(gè)的事件,事件包含創(chuàng)建訂單的字段。 這周Jerry在SAP上海研究院參加了一個(gè)為期4天的Kubernetes培訓(xùn),度過了忙碌而又充實(shí)的4天。Jason,Benny和Peng三位大神的培訓(xùn)干貨滿滿,借此機(jī)會(huì),Jerry和過去的兩位老領(lǐng)導(dǎo)Patrick和Evan敘了敘舊,也拜見了上海SAP圈子里...
摘要:小的時(shí)候,聽過牛頓這樣謙虛的一句話如果說我看得比別人更遠(yuǎn)些,那是因?yàn)槲艺驹诰奕说募绨蛏?。。發(fā)布一個(gè)的事件,事件包含創(chuàng)建訂單的字段。 這周Jerry在SAP上海研究院參加了一個(gè)為期4天的Kubernetes培訓(xùn),度過了忙碌而又充實(shí)的4天。Jason,Benny和Peng三位大神的培訓(xùn)干貨滿滿,借此機(jī)會(huì),Jerry和過去的兩位老領(lǐng)導(dǎo)Patrick和Evan敘了敘舊,也拜見了上海SAP圈子里...
摘要:小的時(shí)候,聽過牛頓這樣謙虛的一句話如果說我看得比別人更遠(yuǎn)些,那是因?yàn)槲艺驹诰奕说募绨蛏?。。發(fā)布一個(gè)的事件,事件包含創(chuàng)建訂單的字段。 這周Jerry在SAP上海研究院參加了一個(gè)為期4天的Kubernetes培訓(xùn),度過了忙碌而又充實(shí)的4天。Jason,Benny和Peng三位大神的培訓(xùn)干貨滿滿,借此機(jī)會(huì),Jerry和過去的兩位老領(lǐng)導(dǎo)Patrick和Evan敘了敘舊,也拜見了上海SAP圈子里...
閱讀 2170·2023-04-26 00:43
閱讀 2689·2021-11-22 15:22
閱讀 3823·2021-11-11 16:55
閱讀 972·2021-11-04 16:06
閱讀 1791·2019-08-30 14:12
閱讀 1004·2019-08-30 14:02
閱讀 3375·2019-08-29 17:05
閱讀 1421·2019-08-29 12:27