Google contact api returns Invalid XML Document error - google-contacts-api

While adding contacts using google contacts api, I have been getting status code 400, with Invalid XML Document error.
If I remove the following line the add contact api succeeds. However, this behaviour is not what I want. I would like to add it to the base group 6.
<gContact:groupMembershipInfo deleted="false"
href="http://www.google.com/m8/feeds/groups/binthi123#gmail.com/base/6"/>
The following is the body of the add new contact api post request:
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" />
<gd:name>
<gd:givenName>1234567890</gd:givenName>
</gd:name>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#mobile" primary="true">
${phone_number}
</gd:phoneNumber>
<gContact:groupMembershipInfo deleted="false" href="http://www.google.com/m8/feeds/groups/binthi123#gmail.com/base/6" />
</atom:entry>

I solved the problem changing the tag <gContact:groupMembershipInfo>in <gd:groupMembershipInfo> , so any tag with <gContact> no longer works but only with <gd:>, this only when you create new contact if you update there isn't any problem

Our team ran into a variant of this problem where the Contacts API was returning "Invalid JSON" 400 error when posting a new contact (via XML). The problem was related to us setting the alt=json parameter; apparently there is a bug on Google's end that gets invoked if you ask for a JSON response from that method.

Related

Invalid HTTP_HOST header: 'api.binance.com'

I keep on getting this error the moment I enabled error messaging in Django. I research about it. This binance thingy is about bitcoin and it is not related to what I'm doing.
Is this an attack that's trying to check/access my Django Web app?
Invalid HTTP_HOST header: 'api.binance.com'. You may need to add 'api.binance.com' to ALLOWED_HOSTS.
Report at /api/v1/time
Invalid HTTP_HOST header: 'api.binance.com'. You may need to add 'api.binance.com' to ALLOWED_HOSTS.
Request Method: GET
I check the api.binance.com. It is like an api and it says "ok"
What's your thought about this?
This is issue just means that external device on the internet is trying to connect on Django however since the the URL " api.binance.com" is not on the allowed list on Django settings.
It is giving error only when you enable the debugging to sent on your email.

Newsletter2Go endpoint /forms/submit{{form_id}}

I created a wrapper for using the newsletter2go endpoint
https://api.newsletter2go.com/forms/submit/{{form_id}}
When I post the request to that ep w/ an form_id I get the following response:
http status: 400
code: 10020
error message: Bad Request (invalid code xxxx)
Im using the id from the n2go backend:
Can anyone tell me whats about the error code 10020? The api docs containing nothing about that.
This is probably because you used big letters in your form_id. I had the same problem. The support told me, that only small letters are allowed.
I found finally out what the form_id have to be. It's the value you see in the Opt-In Email for the n2g argument, for example:
https://subscribe.newsletter2go.com?n2g=dummy-code-here
Otherweise check the sourcecode of the Embedded Form, there is a script in it which contains the form id.
Maybe this helps someone one day.

Change country in Exact API

i am using Exact API with this code https://github.com/picqer/exact-php-client using de example.php file with my RedirectURL, ClientId and ClientSecret the problem is it always responds with "Client not found" error message.
This is the answer of support department of exact:
"Please change the .NL part to .ES. If you have registered an app in the Spanish app center, make sure your oauth calls are also aimed at Exact Online .ES."
My question is: how can i change this .NL part? i´ve search in all the code with no results.
Change the base URL, as documented:
$connection->setBaseUrl('https://start.exactonline.es');

Uncaught SyntaxError: Unexpected token < On Chrome

I know this question has been asked many times but I can't find similarity with my issue. I'm getting this error only in Chrome, in every other browser everything is ok. I return data with JSON in several places but since my code works in other browsers I assume nothing is wrong with it.
Chrome doesn't show me where is error (in my code) it shows me these errors:
This is how I use JSON:
$.post("getData.php", {'id' : id}, function(data){
var obj = jQuery.parseJSON(data);
.
.
.
... some mysqli query
$data = $query->fetch_assoc();
echo json_encode($data);
So I don't see a problem here, can someone help me with this.
You can check your Network (console) and See the answer from the Server ... The "<" will be the first letter of your response. Something like "<"undefined index XY in line Z>"
My solution to this is pretty unbelievable.
<script type="text/javascript" src="/js/dataLayer.js?v=1"></script>
The filename in the src attribute needed to be lowercase:
<script type="text/javascript" src="/js/datalayer.js?v=1"></script>
and that somewhat inexplicably fixed the problem.
In both cases the reference was returning 404 for testing.
Error with Uncaught SyntaxError: Unexpected token < using #Mario answer but that was only part of my problem. Another problem is, javascript doesn't get any data from PHP file. That was solved using this code, inside PHP file: header("Content-Type: text/javascript; charset=utf-8");
This answer is found on this link, where I opened another question to solve this issue: Can't receive json data from PHP in Chrome and Opera
I got the same error ("Uncaught SyntaxError: Unexpected token <" ) at these two lines when testing a sample application .
<script type = "text/javascript" src="raphael-min.js"></script>
<script type = "text/javascript" src="kuma-gauge.jquery.js"></script>
After a control, I realized that, local file locations are not correct and my local server app returns default page as the result. Client app can find the files but the founded files are default page, not the *.js files. So I receive Uncaught SyntaxError: Unexpected token <
I changed to orginal location on the intenet andit solved.
<script type = "text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js"></script>
<script type = "text/javascript" src="//www.jqueryscript.net/demo/Creating-Animated-Gauges-Using-jQuery-Raphael-js-kumaGauge/js/kuma-gauge.jquery.js"></script>
To override the error that you might experience in Chrome (and probably in Safari), try to set the Ajax parameter as dataType: "json". Then you shouldn't call parseJSON() on the obj because the response you'll get comes deserialized.
I have commented my this code : // $('#description').val('<?php echo $_POST['description']; ?>'); and I got that error.
header("Location: route_to_main_page");
I've encountered this problem while having a custom 404 error handling file. Instead of throwing some html content it was suppose to redirect to the main page url. It worked well.
Then I used this as a skeleton for a next project, therefore not changing the "route_to_main_page" actually on the new project (different URL) became a "route_to_external_url" so any 404 errors within your code (missing css stylesheets, js libraries) would return the "Uncaught SyntaxError: Unexpected token <".
I faced similar issue when I moved some of the js files into folders then deployed into production, after some struggle I found out that the js files were not actually got deployed to production. So
make sure that the file for which the error is shown does exist in
the server
the path given is correct
So, In the absence of js file, the server then server responds with as below
<!doctype html>
<html>
<someTag />
<AnotherTag />
</html>
Thats why we get Uncaught SyntaxError: Unexpected token <
It could be that the resource you're trying to request is under restricted access via your web app configuration, i.e. user must be logged for the application to serve the file.
Try adding this to your Web.Config file (this is for .NET applications):
<location path="js/resourcefile.js">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
You can place it anywhere before the closing configuration tag.
If you are trying to perform Ajax file upload or something similar, you have to get rid of displaying further HTML after printing your ajax response text. Probably that gives this error message. If you are using PHP framework you have to follow framework syntax to end the application. If you are coding pure PHP, you can use 'exit' after your ajax response text.
Hope this will help save some ones' time on finding solution for this. :) happy coding!!!
change it to
$.post({
url = 'getData.php',
data : { 'id' id } ,
dataType : 'text'
});
This way ajax will not try to parse the data into json or similar
Seems everyone has difference experiences from this and therfore solutions as well :) This is my "story".
My thing came from a validate.php file fetched with ajax. The output was meant to be :
$response['status'] = $status;
$response['message'] = $message;
$response['param'] = $param;
echo json_encode($response);
And the error that cause the "Unexpected token <" error was simply that in some cases $message hadn't been declared (but only $status and $param). So, added this in the beginning of the code.
$message = ''; // Default value, in case it doesn't get set later on.
So I guess, those "little things" may in this scenario big of quite importance. So be sure to really check your code and making it bulletproof.
Had the same error. My problem was caused from shifting around my project directory, and failing to adjust the path to my static files on the server to reflect the new path (i.e. was ./src/public but should have been ./public).
The only place it worked for me is when I place the scripts in public folder where my index.html resides and then placing these <script type="text/javascript" src="test/test.js"></script> inside <body> tag.
In my case, host had enabled iisnode at my web.config file so I've commented.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<!-- <add name="iisnode" path="*.js" verb="*" modules="iisnode" /> -->
</handlers>
</system.webServer>
</configuration>

Picasa data api and JSON - no output

I'm calling my account's album with the URL in following form:
https://picasaweb.google.com/data/feed/api/user/<user_id>/albumid/<album_id>
This returns an ATOM feed with this URL:
https://picasaweb.google.com/data/feed/api/user/<user_id>/albumid/<album_id>/?alt=json
I get "No album found." error.
Do I have to set up JSON in my account's preferences? Because the method I'm using seems like the proper one - according to the documentation: https://developers.google.com/gdata/docs/json
This: https://picasaweb.google.com/data/feed/api/user/103168604032363426774/albumid/5626814518240219937?alt=json works. It seems like the album you're using doesn't actually exist.
Can you share the URL you're actually using?
Just share album as public.Got to album settings , visible for everyone in the internet