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

Invalid Type : CATEGORY is supported only in minorVersion >= 4 #517

Closed
szymonlipka opened this issue May 6, 2020 · 8 comments
Closed

Invalid Type : CATEGORY is supported only in minorVersion >= 4 #517

szymonlipka opened this issue May 6, 2020 · 8 comments

Comments

@szymonlipka
Copy link

Hey, I'm trying to create item with "Category" type and I'm getting error "Invalid Type : CATEGORY is supported only in minorVersion >= 4". I'm doing something like this:

batch_request = Quickbooks::Model::BatchRequest.new
service = Quickbooks::Service::Batch.new(access_token: access_token, realm_id: realm_id)
item = Quickbooks::Model::Item.new(id: 1, type: "Category", name: "test")
batch_request.add("bId1", item, "create")
batch_response = service.make_request(batch_request)
batch_response.response_items.first.fault.errors
=> #<Quickbooks::Model::Fault::Error:0x00007fedf2f41ce8
  @code="2120",
  @detail="Invalid Type : CATEGORY is supported only in minorVersion >= 4",
  @element="Type",
  @message="Invalid Type",
  @roxml_references=
...

I'm wondering if I'm doing something wrong or maybe type "Category" isn't really allowed for Items and the gem shouldn't allow it?

@drewish
Copy link
Contributor

drewish commented May 6, 2020

That's interesting because the model is showing 33:

If you try it outside of the batch does it give you a different result?

@szymonlipka
Copy link
Author

@drewish ok, I tried and it works when I don't use batch. I don't have to use batches so good enough for me, but I think the issue is still there and should be fixed for batches.

I was trying to overwrite this MINORVERSION variable to 41 but it still didn't work, so unfortunately solution isn't so simple.

@ruckus
Copy link
Owner

ruckus commented May 6, 2020

Thanks for the update. Yeah, having the MINORVERSION specified at the model is not the best solution. Or at least there should be a facility to default to that but allow the user to over-ride at query-time.

This should be doable by overriding each service url_for_query or fetch_by_id and reading it from the options hash. I don't know if there could be a more general way to do it

@ruckus
Copy link
Owner

ruckus commented May 6, 2020

Before now I had not fully looked at the minor version documentation:

https://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/minor-versions#working-with-minor-versions

It suggests you can apply a minorversion query param to all requests globally. That is, it doesn't need to be specified per request.

This would suggest we could do:

  1. implement a minorversion=X query param at the base of all GET requests
  2. The library can hard-code to the latest minorversion
  3. But also accept this to be provided via an over-ride

Quickbooks.platform_minor_version = 42

Thoughts?

@szymonlipka
Copy link
Author

Agree. I think one, configurable minor version for all would be really nice. In my opinion it's a bit misleading that there is possibility that gem in one endpoint uses different version than in other.

@drewish
Copy link
Contributor

drewish commented May 7, 2020

Ah yeah I realized what I'd been doing for this was setting the query param for the whole batch with the version:

      options = { query: { requestid: SecureRandom.uuid, minorversion: 4 } }
      connection.quickbooks.execute_with_retries(logger: logger) do
        connection.quickbooks.service(:batch).make_request(request, options)
      end

Having it as a client level could be nice. Is there every a reason to want to downgrade the version?

@ruckus
Copy link
Owner

ruckus commented May 8, 2020

@drewish @szymonlipka I worked on this in a branch/PR: #518

Basically you can set

Quickbooks.minorversion = X

as needed. The library defaults to the current highest number (47 as of now).

Anyone want to take a look?

@ruckus
Copy link
Owner

ruckus commented May 27, 2020

Pushed gem version 1.0.9 with support for this global minorversion

@ruckus ruckus closed this as completed May 27, 2020
ruckus added a commit that referenced this issue May 30, 2020
* QueryBuilder refactor for handling argument values of all types (not just strings). Thank you @jethrodaniel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants