Sage / SData-2.0

Contains documents pertaining to the SData 2.0 developments
33 stars 10 forks source link

Problem with POSTing #36

Closed galimru closed 9 years ago

galimru commented 9 years ago

Hi!

I can't post data to Sage. I tried send request as shown on image, but i've got error. It is happening with any body content (not empty), in this case "test" as example.

I'm getting next response:

<?xml version="1.0" encoding="utf-8"?>
<sdata:diagnosis xmlns="http://schemas.sage.com/sdata/2008/1" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sdatasync="http://schemas.sage.com/sdata/sync/2008/1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sdata="http://schemas.sage.com/sdata/2008/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:sme="http://schemas.sage.com/sdata/sme/2007" xmlns:http="http://schemas.sage.com/sdata/http/2008/1">
  <sdata:severity>error</sdata:severity>
  <sdata:sdataCode>ApplicationDiagnosis</sdata:sdataCode>
  <sdata:applicationCode xsi:nil="true" />
  <sdata:message>Индекс за пределами диапазона. Индекс должен быть положительным числом, а его размер не должен превышать размер коллекции.
Имя параметра: index</sdata:message>
  <sdata:stackTrace>System.ArgumentOutOfRangeException: Индекс за пределами диапазона. Индекс должен быть положительным числом, а его размер не должен превышать размер коллекции.
Имя параметра: index
   в System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   в System.ThrowHelper.ThrowArgumentOutOfRangeException()
   в System.Collections.Generic.List`1.get_Item(Int32 index)
   в System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 index)
   в Sage.Integration.Accounts50.SDOAdapter.SDORequestManager.PostRequest(IRequest request)
   в Sage.Integration.Accounts50.SDOAdapter.SDOAdapter.PostRequest(IRequest request)
   в Invoke7f0bfa6998904f4abb2990845d892993.Invoke(Object , IRequest )
   в Sage.Integration.Messaging.RequestTargetRegistration.RequestTargetInvoker.Invoke(IRequest request)
   в Sage.Integration.Messaging.Request.Process(RequestTargetInvoker invoker)
   в Sage.Integration.Adapter.AdapterController.RealAdapterController.Process(IRequest request)
   в Sage.Integration.Adapter.AdapterController.RealAdapterController.ProcessWorker(IProtocolRequest protocolRequest)
   в Sage.Integration.Adapter.AdapterController.Process(IProtocolRequest request)
   в Sage.Integration.Messaging.MessagingService.Process(IProtocolRequest protocolRequest)</sdata:stackTrace>
  <sdata:payloadPath />
</sdata:diagnosis>

Are there any ideas?

post-sdata

darroncockram commented 9 years ago

The text "test" is not a valid Sdata payload. You must submit a valid payload for it to be processed successfully. Please see this page in the Sdata specification for details on POST operations: http://sage.github.io/SData-2.0/pages/core/0801/

galimru commented 9 years ago

With valid data (from documentation):

<entry xmlns:sdata="http://schemas.sage.com/sdata/2008/1" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://www.w3.org/2005/Atom">
  <id/>
  <title/>
  <content/>
  <sdata:payload>
    <salesOrder xmlns="http://schemas.sage.com/myContract"
      sdata:uuid="BE7D7445-7FA4-4c67-AC22-5F6446314771">
      <orderDate>2008-03-31</orderDate>
      <contact sdata:key="216"/>
      <subTotal>202.70</subTotal>
      <orderLines>
        <salesOrderLine sdata:uuid="5FB95DE2-8548-48ac-8868-8006238EEBF0">
          <product sdata:key="72"/>
          <orderQty>1</orderQty>
          <unitPrice>81.70</unitPrice>
        </salesOrderLine>
        <salesOrderLine sdata:uuid="A2744351-1891-4365-948D-80A32594A14E">
          <product sdata:key="43"/>
          <orderQty>2</orderQty>
          <unitPrice>60.50</unitPrice>
        </salesOrderLine>
      </orderLines>
    </salesOrder>
  </sdata:payload>
</entry>

post-sdata

darroncockram commented 9 years ago

The problem is the same. The payload is still not valid. I'm afraid you can't just copy the example payload from page on the specification and post it to the feeds. That is just an illustrative example and is not product or contract specific.

The payload must adhere to the instance schema (see this page for details on schemas in Sdata: http://sage.github.io/SData-2.0/pages/core/0402/). Further to this any resources referenced by UUID in the payload must be valid and exist in the same dataset you are posting the salesOrder to.

If possible I would suggest using the SIF when interacting with Sdata feeds as it removes most of these complexities. See this series of videos for further info http://www.youtube.com/playlist?list=PLF56D8511E5ABB680&feature=plcp.

galimru commented 9 years ago

I've looked videos. Where am I can download SIF sources? I'm using Java with Apache Abdera (atom library) so SIF won't solve my problem.

Can you help compose valid request?

Unfortunately, request below not valid.

  <entry>
    <author />
    <content />    
    <title />
    <sdata:payload>
      <crm:tradingAccount sdata:uuid="00000000-0000-0000-0000-000000000000">
        <crm:active>true</crm:active>
        <crm:customerSupplierFlag xsi:nil="true" />
        <crm:companyPersonFlag>Customer</crm:companyPersonFlag>
        <crm:invoiceTradingAccount xsi:nil="true" />
        <crm:openedDate>2015-11-11</crm:openedDate>
        <crm:reference xsi:nil="true" />
        <crm:reference2 xsi:nil="true" />
        <crm:status xsi:nil="true" />
        <crm:name>My company</crm:name>
        <crm:shortName xsi:nil="true" />
        <crm:type xsi:nil="true" />
        <crm:registeredAddress xsi:nil="true" />
        <crm:postalAddresses xsi:nil="true" />
        <crm:shippingAddresses xsi:nil="true" />
        <crm:billingAddresses xsi:nil="true" />
        <crm:phones xsi:nil="true" />
        <crm:emails xsi:nil="true" />
        <crm:website xsi:nil="true" />
        <crm:contacts xsi:nil="true" />
        <crm:deliveryContact xsi:nil="true" />
        <crm:salesPersons xsi:nil="true" />
        <crm:deliveryMethod xsi:nil="true" />
        <crm:deliveryRule xsi:nil="true" />
        <crm:currency>GBP</crm:currency>
        <crm:taxCode xsi:nil="true" />
        <crm:taxReference xsi:nil="true" />
        <crm:taxationCountry xsi:nil="true" />
        <crm:useTaxInclusivePrices xsi:nil="true" />
        <crm:financeBalance xsi:nil="true" />
        <crm:financeLimit xsi:nil="true" />
        <crm:financeBalanceDate xsi:nil="true" />
        <crm:financeStatusFlag xsi:nil="true" />
        <crm:financeStatusText xsi:nil="true" />
        <crm:settlementDiscountType xsi:nil="true" />
        <crm:settlementDiscountAmount xsi:nil="true" />
        <crm:settlementDiscountPercent xsi:nil="true" />
        <crm:settlementDiscountTerms xsi:nil="true" />
        <crm:settlementDiscountTermsCommencement xsi:nil="true" />
        <crm:settlementDiscountIncludedInTotal xsi:nil="true" />
        <crm:paymentTerms xsi:nil="true" />
        <crm:paymentTermsCommencement xsi:nil="true" />
        <crm:orderDiscountType xsi:nil="true" />
        <crm:orderDiscountAmount xsi:nil="true" />
        <crm:orderDiscountPercent xsi:nil="true" />
        <crm:orderText1 xsi:nil="true" />
        <crm:orderText2 xsi:nil="true" />
        <crm:orderLineDiscountType xsi:nil="true" />
        <crm:orderLineDiscountAmount xsi:nil="true" />
        <crm:orderLineDiscountPercent xsi:nil="true" />
        <crm:orderLineText1 xsi:nil="true" />
        <crm:orderLineText2 xsi:nil="true" />
        <crm:invoiceDiscountType xsi:nil="true" />
        <crm:invoiceDiscountAmount xsi:nil="true" />
        <crm:invoiceDiscountPercent xsi:nil="true" />
        <crm:invoiceText1 xsi:nil="true" />
        <crm:invoiceText2 xsi:nil="true" />
        <crm:bankAccounts xsi:nil="true" />
        <crm:tenderType xsi:nil="true" />
        <crm:defaultFulfillmentLocation xsi:nil="true" />
        <crm:pricelists xsi:nil="true" />
        <crm:pricingOverride xsi:nil="true" />
        <crm:accountingType xsi:nil="true" />
        <crm:financialAccounts xsi:nil="true" />
        <crm:primacyIndicator xsi:nil="true" />
        <crm:opportunities xsi:nil="true" />
        <crm:salesQuotations xsi:nil="true" />
        <crm:salesOrders xsi:nil="true" />
        <crm:salesOrderDeliveries xsi:nil="true" />
        <crm:salesInvoices xsi:nil="true" />
        <crm:salesCredits xsi:nil="true" />
        <crm:purchaseOrders xsi:nil="true" />
        <crm:purchaseOrderDeliveries xsi:nil="true" />
        <crm:receipts xsi:nil="true" />
        <crm:interactions xsi:nil="true" />
        <crm:projects xsi:nil="true" />
        <crm:accountSummary xsi:nil="true" />
        <crm:tradingActivities xsi:nil="true" />
        <crm:balance xsi:nil="true" />
        <crm:creditLimit xsi:nil="true" />
        <crm:MTDTurnover xsi:nil="true" />
        <crm:YTDTurnover xsi:nil="true" />
        <crm:priorYTDTurnover xsi:nil="true" />
        <crm:firstInvoiceDate xsi:nil="true" />
        <crm:lastInvoiceDate xsi:nil="true" />
        <crm:lastPaymentDate xsi:nil="true" />
        <crm:accountOpenedDate xsi:nil="true" />
        <crm:lastCreditReviewDate xsi:nil="true" />
        <crm:tradingTerms xsi:nil="true" />
        <crm:standardDiscount xsi:nil="true" />
        <crm:accountOnHold xsi:nil="true" />
        <crm:analysis1 xsi:nil="true" />
        <crm:analysis2 xsi:nil="true" />
        <crm:analysis3 xsi:nil="true" />
        <crm:canChargeCredit xsi:nil="true" />
        <crm:nextCreditReviewDate xsi:nil="true" />
        <crm:additionalDiscount xsi:nil="true" />
        <crm:creditAppliedDate xsi:nil="true" />
      </crm:tradingAccount>
    </sdata:payload>
  </entry>
darroncockram commented 9 years ago

I've looked videos. Where am I can download SIF sources? I'm using Java with Apache Abdera (atom library) so SIF won't solve my problem.

The SIF is not open source I'm afraid but the binaries are installed as part of the Sage 50 Accounts install which it sounds like you already have. It is also available as a standalone installation here https://github.com/Sage/sdata-downloads. However it's only available for .NET so as you say the SIF won't help in your situation.

Can you help compose valid request? Unfortunately, request below not valid.

What resource kind are you trying to post a tradingAccount or a salesOrder? What I'd typically recommend if you're jsut getting started is to issue a template request (see this page in the Sdata spec: http://sage.github.io/SData-2.0/pages/core/0206/) for the resource kind you are trying to create. Then it's just a case of updating the resulting payload with any mandatory information (see the instance schema for details on which fields are mandatory) and post this back to the feeds.

galimru commented 9 years ago

What resource kind are you trying to post a tradingAccount or a salesOrder?

It is tradingAccount resource kind (I've used http://localhost:5493/sdata/accounts50/GCRM/-/tardingAccounts)

I guess that problem not in request because error text for all requests is identical.

If even I doing wrong request witn wrong resource kind, as example http://localhost:5493/sdata/accounts50/GCRM/-/test I getting the same error:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

It's happening with POST, PUT and DELETE method request.

Moreover, the same error is happening if even remove Authorization header.

I thought error text should be more understandable.

darroncockram commented 9 years ago

Ah, do you actually have a dataset exposed to Sdata? What happens if you issue a GET request against the tradingAccounts feed? Are there any datasets shown if you query the endpoints (http://sage.github.io/SData-2.0/pages/core/1403/)?

galimru commented 9 years ago

Endpoints: endpoints

If I doing GET request to tradingAccounts, I get right feed with entries.

darroncockram commented 9 years ago

If I doing GET request to tradingAccounts, I get right feed with entries.

In that case I would try a GET request on a single tradingAccount, update the name property and then issue a PUT with the updated XML. That will definitely take the structure/format of the XML out of the equation. You could also try the same but turn it in to a POST operation - just make sure to update the UUID too.

galimru commented 9 years ago

I've done it!

Problem was actually in wrong request.

Thanks a lot! All the best.

michael-roewin commented 8 years ago

HI Galimru, I'm experiencing the same problem that you've experienced regarding Sage Sdata.. Would it be ok if I request a sample valid xml for the tradingAccount resource kind. Thanks :)