Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error calling EditFacts for multiple facts #63

Open
ghost opened this issue Aug 17, 2016 · 8 comments
Open

error calling EditFacts for multiple facts #63

ghost opened this issue Aug 17, 2016 · 8 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Aug 17, 2016

Hi,
I am trying to edit multiple facts together using this code:
dataAPI.EditFacts(token: rwtoken, patch: patch, aid: aid, dimensions: dimensions);

If patch type is List of Fact class i recive the error message listed below.
If patch type is Fact the operation is successfull.

Error calling EditFacts: { "request_id" : "57b45337d38b6126b73b07ae", "context" : "boi.local.28.io", "type" : "type", "code" : "XPTY0004", "location" : { "module" : "/public/api/facts/PATCH.jq", "line-number" : 69, "line-number-end" : 69, "column-number" : 5, "column-number-end" : 86 }, "description" : "array() can not be treated as type object()", "message" : "</public/api/facts/PATCH.jq>:69,5: type error [err:XPTY0004]: array() can not be treated as type object()" }

Fact class is:
public class Fact
{
public List KeyAspects { get; set; }
public Dictionary<string, string> Aspects { get; set; }
public Profiles Profiles { get; set; }
public string Value { get; set; }
public int Decimals { get; set; }
public List AuditTrails { get; set; }
}

@fcavalieri
Copy link
Contributor

Hello @amit-boi , thanks for the report.

In the EditFacts method, the patch can only be a single object. That is what the not so friendly error is trying to tell you. The patch object is merged into each identified fact as a result of the method call so it must be one. In the C# bindings bodies are defined as object and toString is invoked as necessary.

What is the intended behaviour when you pass multiple patch objects?

Kind regards,
Federico

@fcavalieri fcavalieri self-assigned this Aug 17, 2016
@ghost
Copy link
Author

ghost commented Aug 17, 2016

I want to update all the objects in one call in order to improve performance.
What is the recommanded way to update high number of facts ?

@fcavalieri
Copy link
Contributor

Hello @amit-boi,

to update more than one fact at the same time you don't need to pass multiple patches.
Let's consider a case, we have an archive with aid "open_table" and mark all its invalid facts as valid.

To do so we can:
PATCH http://boi-demo.28.io/v1/_queries/public/api/facts?token=barfoo&xbrl28:Archive=open_table&open=true&boi:FilingStatus=invalid

Body:
{
"Aspects": {
"boi:FilingStatus": "valid"
}
}

This part of the request identifies the facts (all the facts from open_table that are marked as invalid): xbrl28:Archive=open_table&open=true&boi:FilingStatus=invalid
To each of them we set Aspects.boi:FilingStatus to valid.

Are you trying to patch each object with a different patch?

Let me know if this helps,
Federico

@ghost
Copy link
Author

ghost commented Aug 18, 2016

Yes.
I am changing the value of every object so i need diffrent patch for each object.

@fcavalieri
Copy link
Contributor

Hello @amit-boi,
could you make me an example with two facts, two patches and two expected obtained facts? I am trying to fully understand the use case because changing the value of every object does not necessarily imply needing different patches.

The behaviour of the method is:
foreach fact x that matches query parameters
"patch" fact x with the given patch

Thanks and kind regards,
Federico

@ghost
Copy link
Author

ghost commented Aug 18, 2016

If the value of every patch is diffrent and it's for diffrent fact then i think i need diffrent patches.

Anyway, I am trying to do editFacts in parallel threads for high number of facts and is seems to solve the performance issue.

@fcavalieri
Copy link
Contributor

If you want to apply different patches to different facts you need to make multiple requests at the moment. If you pass multiple patches in the same call on every identified fact all patches are applied in order.
(This is not working in your code because the serialization of lists of objects in the body of a request is handled differently.

@ghost
Copy link
Author

ghost commented Aug 24, 2016

i did not understand your second sentence. can you show me an example ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant