2013-05-31 20 views
0

我想修改使用qbxml.Below創建的SalesorPurchase聚合下的現有產品/服務,該代碼是我現在使用的代碼。但它顯示錯誤代碼'400 '。任何人都可以在此引導我。如何使用qbxml更新服務/產品

版本:QuickBooks的在線(QBXML 6.0)

<?xml version="1.0" ?> 
    <?qbxml version="6.0"?> 
    <QBXML>  
    <SignonMsgsRq>  
    <SignonTicketRq>   
    <ClientDateTime>2013-05-31T19:25:26</ClientDateTime>   
    <SessionTicket>V1-92-Q0yzasxa55g3869b5u</SessionTicket> 
    <Language>English</Language>   
    <AppID>70038</AppID>   
    <AppVer>1</AppVer>  
    </SignonTicketRq> 
    </SignonMsgsRq> 
    <QBXMLMsgsRq onError="stopOnError"> 
    <ItemServiceModRq> 
    <ItemServiceMod> 
    <ListID>4</ListID> 
    <EditSequence>0</EditSequence> 
    <Name>QBTubes1</Name> 
    <SalesOrPurchaseMod> 
    <Desc>All Shirts</Desc> 
    <Price>49</Price> 
    <AccountRef> 
     <FullName>Sales</FullName> 
    </AccountRef> 
    </SalesOrPurchaseMod> 
    </ItemServiceMod> 
    </ItemServiceModRq> 
    </QBXMLMsgsRq></QBXML> 

請求方法:

protected static String _doRequest(String xml) throws Exception { 
     String xmlOut = null; 

       try 
       { 
        URL url= new URL(GenericQBXML._appURL); 
        HttpsURLConnection connection =  (HttpsURLConnection)url.openConnection(); 
        connection.setDoOutput(true); 
        connection.setDoInput(true); 

        connection.setRequestProperty("Content-Type", "application/x-qbxml"); 

        PrintWriter out = new PrintWriter(connection.getOutputStream()); 
        out.println(xml); //XML Input 
        out.close(); 
        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); 
        String inputLine = ""; 
       String xmlOut = ""; 
        StringBuffer strOut = new StringBuffer(); 

        while ((inputLine = in.readLine()) != null) 
        { 
         strOut.append(inputLine); 
        } 
        xmlOut = strOut.toString(); 

        in.close(); 
       } 
       catch(ConnectException conEx) 
       { 
        throw new Exception(conEx.getMessage()); 
       } 
       catch(MalformedURLException malformedURLEx) 
       { 
        throw new Exception(malformedURLEx.getMessage()); 
       } 
       catch(IOException ioEx) 
       { 
        throw new Exception(ioEx.getMessage()); 
       } 
       return xmlOut; 
    } 

在此先感謝。

+0

你能後你得到從QuickBooks回到實際的錯誤信息/ XML響應? –

+0

@Keith Palmer在這裏是QuickBooks服務器返回的HTTP響應代碼:400對於URL的響應:https://webapps.quickbooks.com/j/AppGateway –

+0

這表明您在HTTP請求中發送了錯誤的內容。你可以發佈你的代碼和/或你的HTTP請求的其餘部分,而不是一個小小的片段嗎? –

回答

0
   New Request : 


      <?xml version="1.0" ?> 
        <?qbxml version="6.0"?> 
        <QBXML>  
        <SignonMsgsRq>  
        <SignonTicketRq>   
        <ClientDateTime>2013-05-31T19:25:26</ClientDateTime>   
        <SessionTicket>V1-92-Q0yzasxa55g3869b5u</SessionTicket> 
        <Language>English</Language>   
        <AppID>70038</AppID>   
        <AppVer>1</AppVer>  
        </SignonTicketRq> 
        </SignonMsgsRq> 
        <QBXMLMsgsRq onError="stopOnError"> 
        <ItemServiceModRq> 
        <ItemServiceMod> 
        <ListID>4</ListID> 
        <EditSequence>0</EditSequence> 
        <Name>QBTubes1</Name> 
        <SalesOrPurchaseMod> 
        <Desc>All Shirts</Desc> 
        <Price>49</Price> 
        </SalesOrPurchaseMod> 
        </ItemServiceMod> 
        </ItemServiceModRq> 
        </QBXMLMsgsRq></QBXML> 


       I have just removed below code from the original request and it's working now.we can not update Account details through the quick books online.here is the reference 

http://dev.developer.intuit.com/qbSDK-current/OSR/OnscreenRef/index- QBO.html

    <AccountRef>  
         <FullName>Sales</FullName> 
        </AccountRef>