Giter VIP home page Giter VIP logo

Comments (7)

asvyazin avatar asvyazin commented on June 21, 2024
  • Есть два метода GetDocuments в объекте DiadocApi. А поскольку COM не поддерживает перегрузку методов, то в COM-обертке ComDiadocApi второй метод стал называться GetDocuments_2. У первого метода GetDocuments всего два параметра - token и filter. filter - COM-объект Diadoc.Api.DocumentsFilter, который содержит в себе на самом деле все те же самые параметры, только их необязательно все заполнять
  • Поля Counteragents в COM-объекте ICounteragentList нет, есть CounteragentsList, то есть в данном случае должно быть CounteragentsList.CounteragentsList.Item(s).IndexKey

from diadocapi-docs.

enatdne avatar enatdne commented on June 21, 2024

Иначе говоря, есть 2 способа получить документы:

  1. через метод GetDocuments и 2 параметра (token и filter)
    Set filter = CreateObject("Diadoc.Api.DocumentsFilter")
    Set DocumentList = diadoc.GetDocuments(token, filter) --> не работает, ошибка: BaseUrl=https://diadoc-api.kontur.ru, PathAndQuery=/V3/GetDocuments?boxId&filterCategory,AdditionalMessage=Could not get boxId&filterCategory,Additional Message=Could not get boxID from boxID query param, StatusCode = BadREquest, DiadocErrorCode:Http.BadRequest

Если указать filter.Boxid = "368....6002"
filter.FilterCategory = "Invoice.InvoiceWaitingForRecipientSignature"
то будет другая ошибка:
BaseUrl=https://diadoc-api.kontur.ru, PathAndQuery=/V3/GetDocuments?boxId=368а119у-22с1-4124-8efa-Additional Message The server encountered an internal error or misconfiguration and was unbale to complete your request, StatusCode=InternalServerError, DiadocErrorCode:

  1. через метод GetDocuments_2 и несолько параметров?
    Set DocumentList = diadoc.GetDocuments_2(token, Boxid, AnyInvoiceDocumentType.InboundFinished, "", "01.01.2016", "01.08.2016", "", "", "", "", "")
    Не работает, ошибка --> Object required

from diadocapi-docs.

asvyazin avatar asvyazin commented on June 21, 2024

Скопируйте пожалуйста точные параметры запроса и текст ошибки, которую вы получаете, без сокращений.

from diadocapi-docs.

enatdne avatar enatdne commented on June 21, 2024

1 вариант)
Sub API_test()

Dim Key, login, Password, CountINN

Key = Worksheets("Sheet1").Cells(1, 3).Value 'êëþ÷ ðàçðàáîò÷èêà
login = Worksheets("Sheet1").Cells(2, 3).Value
Password = Worksheets("Sheet1").Cells(3, 3).Value
CountINN = Worksheets("Sheet1").Cells(4, 3).Value

Dim i, diadoc, filter, token
i = 2
Set diadoc = CreateObject("Diadoc.Api.ComDiadocApi2")
diadoc.Initialize Key, "https://diadoc-api.kontur.ru"

Set filter = CreateObject("Diadoc.Api.DocumentsFilter")
filter.Boxid = "368f119e-22c1-4124-8efa-c6cfffa06002"
filter.FilterCategory = "Invoice.InvoiceWaitingForRecipientSignature"      

token = diadoc.AuthenticateWithPassword(login, Password)
Set DocumentList = diadoc.GetDocuments(token, filter)

End Sub

Ошибка:
Run-time error '-2146233079 (80131509)':
BaseURL=https://diadoc-api.kontur.ru, PathAndQuery=/V3/GetDocuments?boxId=368f119e-22c1-4124-8efa-AdditionalMessage=The server encountered an internal error or misconfiguration and was unable to complete your requestm StatusCode =InternalServerError, DiadocErrorCode:

2 вариант)
Sub API_test()

Dim Key, login, Password, CountINN

Key = Worksheets("Sheet1").Cells(1, 3).Value 'êëþ÷ ðàçðàáîò÷èêà
login = Worksheets("Sheet1").Cells(2, 3).Value
Password = Worksheets("Sheet1").Cells(3, 3).Value
CountINN = Worksheets("Sheet1").Cells(4, 3).Value

Dim i, diadoc, filter, token
i = 2
Set diadoc = CreateObject("Diadoc.Api.ComDiadocApi2")
diadoc.Initialize Key, "https://diadoc-api.kontur.ru"

Set filter = CreateObject("Diadoc.Api.DocumentsFilter")
filter.Boxid = "368f119e-22c1-4124-8efa-c6cfffa06002"
filter.FilterCategory = "Invoice.InvoiceWaitingForRecipientSignature"      

token = diadoc.AuthenticateWithPassword(login, Password)

Set DocumentList = diadoc.GetDocuments_2(token, Boxid, AnyInvoiceDocumentType.InboundFinished, "", "01.01.2016", "01.08.2016", "", "", "", "", "")

End Sub
Ошибка:
Run-time error '424':
Object required

from diadocapi-docs.

enatdne avatar enatdne commented on June 21, 2024

По поводу CounterAgents: " Поля Counteragents в COM-объекте ICounteragentList нет, есть CounteragentsList , то есть в данном случае должно быть CounteragentsList.CounteragentsList.Item(s).IndexKey " -->

Sub API_test()

Dim Key, login, Password, CountINN

Key = Worksheets("Sheet1").Cells(1, 3).Value 'êëþ÷ ðàçðàáîò÷èêà
login = Worksheets("Sheet1").Cells(2, 3).Value
Password = Worksheets("Sheet1").Cells(3, 3).Value
CountINN = Worksheets("Sheet1").Cells(4, 3).Value

Dim i, diadoc, filter, token
i = 2
Set diadoc = CreateObject("Diadoc.Api.ComDiadocApi2")
diadoc.Initialize Key, "https://diadoc-api.kontur.ru"
token = diadoc.AuthenticateWithPassword(login, Password)

'---------------------------------------------------------------

'Ñîçäàåì îáúåêò DocumentsTask, çàïîëíÿåì ñâîéñòâà, âûïîëíÿåì ìåòîä è ïîëó÷àåì ñïèñîê äîêóìåíòîâ
Dim Organization, Boxid, DocumentsTask, DocumentList, Document

Boxid = "368f119e-22c1-4124-8efa-c6cfffa06002"
Set Organization = diadoc.GetOrganizationById(Boxid)

Dim inn_s, kpp_s, CounteragentList, s, s_id, IndexKey

'Ïîëó÷àåì ñïèñîê êîíòðàãåíòîâ ñ çàäàííûìè ÈÍÍ/ÊÏÏ
Set CounteragentList = diadoc.GetCounteragents(token, Boxid, Null, Null)

       For s = 0 To CounteragentList.TotalCount
         s_id = CounteragentList.TotalCount
         IndexKey = CounteragentsList.CounteragentsList.Item(s).IndexKey
         Worksheets("Sheet3").Cells(i, 1).Value = s_id
         Worksheets("Sheet3").Cells(i, 2).Value = IndexKey
        s = s + 1
        Next s
        Worksheets("Sheet3").Activate

End Sub

Ошибка:
Ошибка:
Run-time error '424':
Object required

from diadocapi-docs.

asvyazin avatar asvyazin commented on June 21, 2024

в GetDocuments вы вместо boxId передаете orgId, это разные идентификаторы

boxId должен быть видимо bdc1e5e9-b096-4c8d-bc02-958b2d9ec379

from diadocapi-docs.

asvyazin avatar asvyazin commented on June 21, 2024

А в GetCounteragents как раз нужно orgId, тут все правильно

Ошибка может быть из-за того, что переменная s вышла за границы массива CounteragentsList. TotalCount - это общее число контрагентов, а GetCounteragents по-умолчанию возвращает максимум 100

from diadocapi-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.