What is the best way to prevent to see "options are not unique" error? - http-headers

When I want to update a specific product how can I determine non unique options and prevent to see 'options are not unique' error?
This is xml of create product:
my $xml = qq~<?xml version="1.0" encoding="UTF-8"?>
<product>
<title>$title</title>
<body-html>$description</body-html>
<vendor>$vendor</vendor>
<product-type>$product_type</product-type>
<published type="boolean">$publish_status</published>~;
$xml.=qq{<variants type="array">
<variant>
<title>$title</title>
<option1>$title</option1>
<option2 nil="true"></option2>
<option3 nil="true"></option3>};
$xml.=qq{<price>$price</price>
<sku>$sku</sku>
<position type="integer">1</position>
</variant>
</variants>};
$xml.='</product>';
This is the xml of modify product:
my $xml = qq~<?xml version="1.0" encoding="UTF-8"?>
<product>~;
$xml.=qq~<title>$title</title>~;
$xml.=qq~<id type="integer">$id_product</id>~;
$xml.=qq~<body-html>$description</body-html>
<vendor>$vendor</vendor>
<product-type>$product_type</product-type>
<published type="boolean">$publish_status</published>
<variants type="array">
<variant>~;
$xml.= qq~<title>$title</title>~;
$xml.= qq~<option1>$title</option1>~;
$xml.= qq~<option2 nil="true"/>~;
$xml.= qq~<option3 nil="true"/>~;
$xml.=qq~<price>$price</price>
<sku>$sku</sku>
<position type="integer">1</position>
</variant>
</variants>~;
$xml.='</product>';
I am getting "options are not unique" error when I try to modify specific product. option1 tag content is same as previous option1 tag content. Is it a bug? or option1 value is must be different previous one? What I have to do not see "options are not unique" error?
Thanks in Advance

Yes, there is a bug in the API when updating products and you are passing in an option that already exists. The error message is actually quite misleading and is being worked on at the moment.

Related

Davical Sync-Token web request

I am trying not to re-invent the wheel here...
I have found some nice documentation on CalDav sync implementation there
According to its website, DaviCal is rfc6578-compliant since v. 0.9.8 (see here).
I therefore first send my request to get the sync token as follows:
PROPFIND http://my_cal_srv/user/calendar_path HTTP/1.1
Content-Type: application/xml; charset="utf-8"
<?xml version="1.0" encoding="utf-8" ?>
<d:propfind xmlns:d='DAV:'>
<d:prop>
<d:displayname />
<d:sync-token />
</d:prop>
</d:propfind>
This returns data as expected:
<?xml version="1.0" encoding="utf-8" ?>
<multistatus xmlns="DAV:">
<response>
<href>/caldav.php/user/calendar_path/</href>
<propstat>
<prop>
<displayname>My Calendar</displayname>
<sync-token>data:,9</sync-token>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
So far so good, I have a token, it's "data: ,9". So, let's just try to get changes since 8, the token I had when I queried the server prior to adding some event.
REPORT http://my_cal_srv/user/calendar_path HTTP/1.1
Content-Type: application/xml; charset="utf-8"
<?xml version="1.0" encoding="utf-8" ?>
<d:sync-collection xmlns:d="DAV:">
<d:sync-token>8</d:sync-token>
<d:sync-level>1</d:sync-level>
<d:prop>
<d:getetag/>
</d:prop>
</d:sync-collection>
The answer is:
<?xml version="1.0" encoding="utf-8" ?>
<multistatus xmlns="DAV:">
<response>
<href>/caldav.php/user/path/86166f9c-3e2e-4242-9a28-0f3bfb1dd67a-caldavsyncadapter.ics</href>
<propstat>
<prop>
<getetag>"5ed2101b0c867e490dbd71d40c7071bb"</getetag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/user/path/cb354fab-b41d-49ad-8a4f-8d68c9090ea0.ics</href>
<propstat>
<prop>
<getetag>"334892703f4151024e9232eab9b515a7"</getetag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<sync-token>data:,9</sync-token>
</multistatus>
After deleting an entry (so I get sync-token 10, and still compare using token 8), I get following result :
<?xml version="1.0" encoding="utf-8" ?>
<multistatus xmlns="DAV:">
<response>
<href>/caldav.php/user/cal_path/86166f9c-3e2e-4242-9a28-0f3bfb1dd67a-caldavsyncadapter.ics</href>
<status>HTTP/1.1 404 Not Found</status>
</response>
<response>
<href>/caldav.php/user/cal_path/cb354fab-b41d-49ad-8a4f-8d68c9090ea0.ics</href>
<propstat>
<prop>
<getetag>"334892703f4151024e9232eab9b515a7"</getetag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<sync-token>data:,10</sync-token>
</multistatus>
So I am a little confused here as I don't really know how to interpret these results...
Could anybody please explain to me how to extract the sync info from here? It is a little hard to figure out the changes types because the ICS namings are unclear...
Thanks in advance for helping out... And merry X-Mas !
Regards,
N.
That you get a "data:,9" doesn't imply you can actually query "data:,8" or ,7 etc. Sync tokens are opaque and do NOT give you a versioning system (you need sth like DAV Versioning Extensions for that).
DAV sync-tokens are a simple optimization technique - nothing more. They are completely opaque to the client and the server can expire sync tokens at any time (and is not required to save tombstones and such). Eg a server which can't store tombstones can simply expire tokens on DELETE requests.
The way you use sync-tokens is:
to figure out which child collections of a parent collection need to be re-synced
to optimize syncing of a the resources within a child collection
1) Which child collections need to be synced
Assume you have a collection of calendars (e.g. my_cal_srv/user/) and you do a PROPFIND Depth:1 on this collection, asking for the sync-tokens of the child collections. If those don't match the ones of your clients cache anymore, you know you need to perform a sync of just those child collections.
Note: do NOT use the token you got back from this request to sync the child collection (which is what you do above). It might have expired already. Within sync-reports only use tokens you got from sync-reports!
2) Optimizing syncing of the collection contents
Again: sync-token's are an optimization, nothing more. You always need to be prepared to get an (in)valid-sync-token precondition error (which means the server expired the token) and do a full refetch of the collection contents! And then compare that (URL,ETag) to your cached version to figure out what the changes are. (essentially all the steps you need to do when you have a server which doesn't support sync-reports).
If you get a sync-token in the sync-report results, you can then use it in the next sync-request. If the server still has the state, it'll just give you the changes. If it expired the token, it'll give you the sync-token error.
Note: In case it isn't obvious - in the very first sync-request you don't (can't) provide a token. You run the query w/o a token and get back all the contents. You do the same again if the server sends you an (in)valid-sync-token error.
You're not doing a correct request. In your request you have:
<d:sync-token>8</d:sync-token>
But this should be:
<d:sync-token>data:,8</d:sync-token>
Aside from that, the first response you are getting tells you that:
These resources have been changed or newly created:
/caldav.php/user/path/86166f9c-3e2e-4242-9a28-0f3bfb1dd67a-caldavsyncadapter.ics
/caldav.php/user/path/cb354fab-b41d-49ad-8a4f-8d68c9090ea0.ics
The second response tells you:
This resource has been changed or newly created:
/caldav.php/user/cal_path/cb354fab-b41d-49ad-8a4f-8d68c9090ea0.ics
This resource has been deleted:
/caldav.php/user/cal_path/86166f9c-3e2e-4242-9a28-0f3bfb1dd67a-caldavsyncadapter.ics

Inuit TimeActivity Create: The request sent by the client was syntactically incorrect

I am trying to test my ability to import TimeActivity records and even when using the sample Create Request XML for TimeActivity I get an error:
Apache Tomcat/7.0.23 - Error report HTTP Status 400 - type Status reportmessage description The request sent by the client was syntactically incorrect ().Apache Tomcat/7.0.23
below is my sample xml create request (pulled from https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/timeactivity)
<?xml version="1.0" encoding="utf-8"?>
<TimeActivity xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns="http://www.intuit.com/sb/cdm/v2">
<TxnDate>2011-08-03-07:00</TxnDate>
<NameOf>Vendor</NameOf>
<Vendor>
<VendorIdidDomain="QBO">3793</VendorId>
</Vendor>
<CustomerId>3794</CustomerId>
<ItemId>3</ItemId>
<ClassId>1</ClassId>
<StartTime>2011-08-30T11:45:00-07:00</StartTime>
<EndTime>2011-08-30T13:15:00-07:00</EndTime>
<Taxable>true</Taxable>
<HourlyRate>10.5</HourlyRate>
<BillableStatus>Billable</BillableStatus>
<Hours>10</Hours>
<Minutes>5</Minutes>
<Description>This is a Description</Description>
</TimeActivity>
What am I doing wrong here?
Sharing a sample TimeActivity create request. Please check other reference attributes like Vendor, Class etc. It should work.
<?xml version="1.0" encoding="utf-8"?>
<TimeActivity xmlns='http://www.intuit.com/sb/cdm/v2'>
<TxnDate>2012-08-30-07:00</TxnDate>
<NameOf>Employee</NameOf>
<Employee>
<EmployeeId>11</EmployeeId>
</Employee>
<CustomerId>2</CustomerId>
<JobId>4</JobId>
<BillableStatus>Billable</BillableStatus>
<HourlyRate>50.0</HourlyRate>
<StartTime>2012-08-30T11:45:00-07:00</StartTime>
<EndTime>2012-08-30T13:15:00-07:00</EndTime>
<Description/>
</TimeActivity>
There should be couple of small changes in the sample request ( We will update the doc )
<?xml version="1.0" encoding="utf-8"?>
<TimeActivity xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns="http://www.intuit.com/sb/cdm/v2">
<NameOf>Vendor</NameOf>
<Vendor>
<VendorId idDomain="QBO">5</VendorId>
</Vendor>
<CustomerId>2</CustomerId>
<ItemId>3</ItemId>
<Taxable>true</Taxable>
<HourlyRate>10.5</HourlyRate>
<BillableStatus>Billable</BillableStatus>
<Hours>10</Hours>
<Minutes>5</Minutes>
<Description>This is a Description</Description>
</TimeActivity>
First replace all the reference values with the same of your test data.
For ex - VendorId, Class, Item and Customer
There are two bugs in the sample request.
1. There should be a space between 'VendorId' and 'idDomain' ( Ref -5th line of the req )
2. According to the doc, " Either method of indicating duration can be entered, but not both. Hours/Minutes OR StartTime/EndTime is required."
So plz remove any one of these. ( I've removed StartTime/EndTime )
Otherwise you'll get the error which you have mentioned above.
That is - Response code 400, Error msg - TIME_ACTIVITY_MULTIPLE_DURATION_TYPES_PRESENT
Please let us know if the above changes work for you.
I tried the same XML in Api Explorer. It worked fine for me. PFB snapshot. Please check if you are facing any encoding issue.
Please let me know if it works for you.

CA1703 CodeAnalysis Error and CasingExceptions

I have a text resource "{0} by Test GmbH" which is correctly spelled because GmbH is the official Abbreviation for "Gesellschaft mit beschränkter Haftung". I understand that Microsoft CodeAnalysing tries to tokenize it into "Gmb" and "H" however I think it should be possible to introduce this term as known with that specific spelling and casing with this CodeAnalysingDictionary:
<?xml version="1.0" encoding="utf-8" ?>
<Dictionary>
<Words>
<Unrecognized>
</Unrecognized>
<Recognized>
<Word>Gmbh</Word>
</Recognized>
<Deprecated>
</Deprecated>
<DiscreteExceptions>
<Term>GmbH</Term>
</DiscreteExceptions>
</Words>
<Acronyms>
<CasingExceptions>
<Acronym>GmbH</Acronym>
</CasingExceptions>
</Acronyms>
</Dictionary>
However it does not work out:
CA1703 Resource strings should be spelled correctly
In resource 'MyCode.Properties.Resources.resx',
referenced by name 'CopyrightWithCompanyName',
correct the spelling of 'Gmb' in string value '{0} by Test GmbH'.
How can I adjust the dictionary correctly?
Actually, provided that GmbH should be interpreted as a compound word that consists of the words Gmb and H, the casing of GmbH is correct.
So, in order for GmbH to be seen as valid by Code Analysis and thereby eliminate CA1703, simply add gmb as a recognized word to your custom dictionary file:
<Dictionary>
<Words>
<Recognized>
<Word>gmb</Word>
<!-- ... -->
</Recognized>
<!-- ... -->
</Words>
<!-- ... -->
</Dictionary>
I confirmed that this works in Visual Studio 2013.
According to http://msdn.microsoft.com/en-us/library/bb514188.aspx#bkmk_dictionaryacronymscasingexceptionsacronym
entries in the CasingExceptions are only applied to CA1709: Identifiers should be cased correctly, not to resources.
I have the exact same problem but no solution other then suppress the warning

What does this web.xml error mean?

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
Referenced file contains errors (http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd). For more information, right click on the message in the Problems View and select "Show Details..."
The errors below were detected when validating the file "web-app_2_5.xsd" via the file "web.xml". In most cases these errors can be detected by validating "web-app_2_5.xsd" directly. However it is possible that errors will only occur when web-app_2_5.xsd is validated in the context of web.xml.
In details, I see a bunch of these:
s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than xs:appinfo and xs:documentation. Saw 'var _U="undefined";'
If you replace j2ee by javaee, it will work fine.
EDIT :
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
Edit:
To know anything further related to this error. Please follow the Link. Here you will find schemas for Java EE deployment descriptors (web.xml).
replace
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
with
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee;http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
The solution is that you have to put semicolon between URLs
I am sure you will not get the error again :)
I suggest you add ; between 2 passages:
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee and http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
Like this:
:xsi:schemaLocation="http://java.sun.com/xml/ns/javaee;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
Add semicolon between xsi:schemaLocation just as shown below
"http://java.sun.com/xml/ns/javaee;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
This resolved my this error in <servlet-name> tag line as well.
"cvc-id.3: A field of identity constraint 'web-common-servlet-name-uniqueness' matched element 'web-app', but this element does not have a simple type."
In my case, I had replaced
xsi:schemaLocation="http://java.sun.com/../.."
with
xsi:schemaLocation="http://xmlns.jcp.org/../.."
Cheers!
On the surface it appears that the schemaLocation is wrong. Resolving it appears to redirect to a HTML page rather than a XSD schema.
I would suggest simply removing this line unless you really want to do XSD validation at runtime. Bear in mind the relevant parts will be validated by your servlet container.
Replacing the schemaLocation as below has resovled the error for me:
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/j2ee; http://xmlns.jcp.org/xml/ns/j2ee/web-app_2_4.xsd"

WiX: Define made in included file not avaible from wxs-fragment-file

I have a defines.wxi-file which contains some good definitions used in all my wxs-files.
When I attempt to reference the defined value from one of the <Fragment>-files I get Undefined preprocessor variable '$(var.IMAGE_FOLDER)' back in my face.
I guess there is something trivial I am missing here...
Any ideas?
Edit 19:th April.
Found that issue only occurs if reference from a Fragment-file.
Re-wrote sample to match that.
defines.wxi
<Include>
<?define IMAGE_FOLDER="Images" ?>
</Include>
some-Fragment.wxs
<Fragment>
<?Include defines.wxi ?>
<Component Id='c.Images' Guid=".." Directory='INSTALLDIR.Images' >
<File Id='f.sample.jpg' Source='$(var.IMAGE_FOLDER)sample.jpg' Name='sample.jpg' />
</Component>
Solved it.
Where it in the sample says:
<?Include defines.wxi ?>
it should be lower case...
<?include defines.wxi ?>
then it works like a charm!
/L
Ok, another try.
Do you reference anything in that <Fragment/> from the main <Product/> ? The contents of the fragment are visible to the rest of the code in case you reference anything from it. For instance, you can reference a component (<ComponentRef/>) or component group (<ComponentGroupRef/>). Once anything is referenced, the entire fragment is included.
Hope this helps.
In the text of the error message you provided it says "Undefined preprocessor variable '$(var.MAGE_FOLDER)'", not $(var.IMAGE_FOLDER) - the leading 'I' is missing. This made me think that you reference the same variable somewhere in the rest of your code, but misspelling it.
In this case, the candle.exe is absolutely right - it can find IMAGE_FOLDER, but can't find MAGE_FOLDER.
Hope this is the case and you'll fix it quickly. ;-)