add XML request body to Oauth IConsumerRequest

你说的曾经没有我的故事 提交于 2019-12-08 19:03:30

this worked.Below is the example code i got from intuit forums- https://idnforums.intuit.com/messageview.aspx?catid=86&threadid=18870&enterthread=y

 //using DevDefined.OAuth.Consumer;
//using DevDefined.OAuth.Framework;

protected void GetBalanceSheet()
{
    OAuthConsumerContext consumerContext = new OAuthConsumerContext
    {
        ConsumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString(),
        SignatureMethod = SignatureMethod.HmacSha1,
        ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"].ToString()
    };

    OAuthSession oSession = new OAuthSession(consumerContext, "https://oauth.intuit.com/oauth/v1/get_request_token",
                            "https://workplace.intuit.com/Connect/Begin",
                            "https://oauth.intuit.com/oauth/v1/get_access_token");

    oSession.ConsumerContext.UseHeaderForOAuthParameters = true;

    oSession.AccessToken = new TokenBase
    {
        Token = Session["accessToken"].ToString(),
        ConsumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString(),
        TokenSecret = Session["accessTokenSecret"].ToString()
    };

    var body = "<AdvancedReportQuery xmlns=\"http://www.intuit.com/sb/cdm/v2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.intuit.com/sb/cdm/v2 ..//RestDataFilter.xsd\"><BalanceSheetStd><OfferingId>ipp</OfferingId><EndTransactionDate>2012-06-01</EndTransactionDate></BalanceSheetStd></AdvancedReportQuery>";

    IConsumerRequest conReq = oSession.Request();
    conReq = conReq.Post().WithRawContentType("text/xml").WithRawContent(System.Text.Encoding.ASCII.GetBytes(body)); ;
    conReq = conReq.ForUrl("https://services.intuit.com/sb/advancedreport/v2/508053445");
    try
    {
        conReq = conReq.SignWithToken();
    }
    catch (Exception ex)
    {
        throw ex;
    }

    string serviceResponse = conReq.ReadBody();

}

Karthi, It sounds like you are trying to do a GET request and add content to the body which would cause that error.

Please refer to the documentation on constructing the header for your request here: https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0100_Calling_Data_Services/0010_Request_Header

regards, jarred

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!