Why my PUT request using the google spreadsheet isn’t working? - google-sheets

I’ve been through every step mentioned here https://developers.google.com/google-apps/spreadsheets/#changing_contents_of_a_cell using the protocol and submitting the requests, right now, with POSTMAN before doing an actual script.
On the step of editing a cell via PUT i get a 403 Forbidden with the error "If-Match or If-None-Match header or entry etag attribute required”.
Right now my request URL is:
PUT https://spreadsheets.google.com/feeds/cells/MY_SPREADSHEET_ID/od6/private/full/R1C1?v=3.0
Headers:
Authorization Bearer {my access token}
Content-Type application/atom+xml
Raw
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:gs="http://schemas.google.com/spreadsheets/2006">
<id>https://spreadsheets.google.com/feeds/cells/MY_SPREADSHEET_ID/od6/private/full/R1C1</id>
<link rel="edit" type="application/atom+xml"
href="https://spreadsheets.google.com/feeds/cells/MY_SPREADSHIT_ID/od6/private/full/R1C1"/>
<gs:cell row="1" col="1" inputValue="hello"/>
</entry>
Any ideas please?
ps.: if I remove the ?v=3.0 there will be another error demanding the version

You should add the header If-Match:*
It should work out of the box that way, however, more on subject can be found on http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

Related

The request was missing an Authentification Key FCM Token

I am trying to hit using postman firebase url but it is giving me error.
I have setup all the things but it still it is giving me error
Here is the error which I am getting on postman
<HTML>
<HEAD>
<TITLE>The request was missing an Authentification Key (FCM Token). Please, refer to section "Authentification" of the FCM documentation, at https://firebase.google.com/docs/cloud-messaging/server.</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>The request was missing an Authentification Key (FCM Token). Please, refer to section "Authentification" of the FCM documentation, at https://firebase.google.com/docs/cloud-messaging/server.</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
These things I am adding <br/>
url = 'https://fcm.googleapis.com/fcm/send'<br/>
method = POST<br/>
Headers <br/>
Authorization = 'FIREBASE_SERVER_API_KEY'<br/>
Content-Type = application/json<br/>
Body =
"{"registration_ids":["ids"],"priority":"high\",\"data\":{\"notification_id\":76,\"title\":\"dvxcv\",\"description\":\"xcvxv\",\"image\":\"/uploads/image/image/37513/Screenshot_from_2016-10-17_10_43_59.png\"}}"
All you need to do first in Header
Authorization: key='FIREBASE_SERVER_API_KEY'
And you are having problems with json parsing you have to remove '/'
{"registration_ids":["ids"],"priority":"high","data":{"notification_id":76,"title":"dvxcv","description":"xcvxv","image":"/uploads/image/image/37513/Screenshot_from_2016-10-17_10_43_59.png"}}
Edit
For any confusion follow my tutorial
how to integrate firebase with ruby on rails
Under Headers, Authorization: key=AAAA.....
HAVE TO ADD "key=" in front of the Firebase Server key token!!!

Make POST request from Mule ESB

I'm stuck with making correct HTTP request to web server (running under PHP).
I need to send POST request with property json and some value, for example { "employee_id":191, "date":"2015-08-11", "time":"14:26:00" }.
It's working if I make a request from Postman or cURL for example, the request will look something like this
POST /DeliveryDetails/ HTTP/1.1
Host: 192.168.0.100:80
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
json=%7B+%22employee_id%22%3A191%2C+%22date%22%3A%222015-08-11%22%2C+%22time%22%3A%2214%3A26%3A00%22+%7D
Also I can send with conntent type multipart/form-data
POST /DeliveryDetails/ HTTP/1.1
Host: 192.168.0.100:80
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="json"
{ "employee_id":191, "date":"2015-08-11", "time":"14:26:00" }
----WebKitFormBoundary7MA4YWxkTrZu0gW
or with cURL
curl -d "json={ \"employee_id\":191, \"date\":\"2015-08-11\", \"time\":\"14:26:00\" }" http://192.168.0.100:80/DeliveryDetails/
But when I'm trying to make request from Mule ESB it's not working since the request is incorrect.
The flow looks like this
<sub-flow name="my-flow">
<logger message="Request: #[payload]" level="INFO" doc:name="Log request"/>
<http:request config-ref="request-HTTP" path="/DeliveryDetails/" method="POST" doc:name="HTTP call" />
<object-to-string-transformer doc:name="Object to String"/>
<logger message="Response: #[payload]" level="INFO" doc:name="Log response"/>
</sub-flow>
#[payload] contains the value { "employee_id":191, "date":"2015-08-11", "time":"14:26:00" }
and if I do it like this the body would simply contain it (without additional information like Content-Type, I think thats the problem).
I have tried to add query-param
<http:request-builder >
<http:query-param paramName="json" value="#[payload]" />
</http:request-builder>
or use message-properties-transformer
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="json" value="#[payload]"/>
</message-properties-transformer>
but the result is still the same.
EDIT
The HTTP configuration look like this
<http:request-config name="request-HTTP"
host="192.168.0.100"
port="80"
doc:name="HTTP Request Configuration" />
Also tried to set Content-Type with
<set-property propertyName="Content-Type" value="application/x-www-form-urlencoded" doc:name="Property"/>
and
<http:request-builder>
<http:query-param paramName="json" value="#[payload]"/>
<http:header headerName="Content-Type" value="application/x-www-form-urlencoded"/>
</http:request-builder>
However the body I'm receiving is still just payload, without other properties for example json= or Content-Disposition: form-data; name="json"
Since the payload is just the JSON data, that's what will be sent in most scenarios. Your curl example sets the "json=" part to the body. So there are a couple of options here:
Modify the payload to add the body you want as you do with curl and set the Content-Type to application/x-www-form-urlencoded.
Send multipart content by adding the data as an attachment. In your case try:
<sub-flow name="my-flow">
<logger message="Request: #[payload]" level="INFO" doc:name="Log request"/>
<set-attachment attachmentName="json" value="#[payload]" contentType="application/json"/>
<http:request config-ref="request-HTTP" path="/DeliveryDetails" method="POST" doc:name="HTTP call" />
<object-to-string-transformer doc:name="Object to String"/>
<logger message="Response: #[payload]" level="INFO" doc:name="Log response"/>
</sub-flow>
Set the payload to be a map containing a key "json" with the payload as value. This should make Mule send a form request without you setting the Content-Type explicitly to application/x-www-form-urlencoded.
HTH.
You need to put path="/DeliveryDetails"
You can follow the following config :-
<http:request-config name="HTTP_Request_Configuration" host="192.168.0.100" port="80" doc:name="HTTP Request Configuration"/>
and in the Mule flow or sub flow and set the Content-Type as follows:-
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<http:request config-ref="HTTP_Request_Configuration" path="/DeliveryDetails" method="POST" doc:name="HTTP call" />
<logger message="Input JSON message ****** #['\n'+ message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
You can configure the Content-Type here as per your requirement
You can also refer here :- How do I force the HTTP Request Connector to use a certain Content-Type?

cannot get RTMP URL and stream key

I am developing code using the youtube API for live streaming. What I have done
I have registered a project in google and gotten client_id, client_secret, and
developer ID
I have done OAuth 2.0 and gotten the code and exchanged it to AUTH_TOKEN
I can create a live event by posting to domain gdata.youtube.com
with request
/feeds/api/users/default/live/events
with header
Authorization: Bearer AUTH_TOKEN
GData-Version: 2
Content-Type: application/atom+xml
X-GData-Key: key=DEV_ID
with content
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:media='http://search.yahoo.com/mrss/'
xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<title>Test</title>
<summary>Test gogogogo!</summary>
<content type='application/atom+xml'>
<entry>
<yt:private/>
<yt:cdn name='primary'>
<media:content yt:format='18'/>
<media:content yt:format='19'/>
</yt:cdn>
</entry>
</content>
<yt:when start='2013-07-05T22:00:00.000Z'/>
</entry>
This returns HTTP code : 201 and my live event is created, but the returned data
does not include STREAM KEY AND RTMP URL. I need these data to start my live
event automatically.
the return data
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:app='http://www.w3.org/2007/app'
xmlns:media='http://search.yahoo.com/mrss/'
xmlns:gd='http://schemas.google.com/g/2005'
xmlns:yt='http://gdata.youtube.com/schemas/2007'
gd:etag='W/"CkEHR347eCp7I2A9WhFQEE0."'>
<id>tag:youtube.com,2008:live:event:XXXXXXXXXXXXXXXXXXXX</id>
<published>2013-07-05T05:03:56.000Z</published>
<updated>2013-07-05T05:03:56.000Z</updated>
<app:edited>2013-07-05T05:03:56.000Z</app:edited>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://gdata.youtube.com/schemas/2007#liveEvent'/>
<title>Test</title>
<summary>Test gogogogo!</summary>
<content type='application/atom+xml'
src='http://gdata.youtube.com/feeds/api/users/XXXXXXX/live/videos/XXXXXXXXX'/>
<link rel='self' type='application/atom+xml'
href='http://gdata.youtube.com/feeds/api/users/XXXXXXXXXXXXXXX/live/events/XXXXXXXXXXXXXXXXXX'/>
<link rel='edit' type='application/atom+xml'
href='http://gdata.youtube.com/feeds/api/users/XXXXXX/live/events/XXXXXXXXXXXXXXXXXXXXXX'/>
<author>
<name>XXXXXX</name>
<uri>http://gdata.youtube.com/feeds/api/users/XXXXXXXXXX</uri>
<yt:userId>XXXXXXXXXXXXX</yt:userId>
</author>
<media:group>
<media:description type='plain'>Test gogogogo!</media:description>
<media:title type='plain'>Test</media:title>
</media:group>
<yt:status>pending</yt:status>
<yt:when start='2013-07-05T22:00:00.000Z'/>
</entry>
If I manually login youtube and click on my create live event, I can see my
stream key and RTMP URL there. And I can use they to start streaming manually
So my problem is: how can I get STREAM KEY and RTMP URL automatically (by API
request)?
----EDIT----
based on https://developers.google.com/youtube/2.0/developers_guide_protocol_managing_live_events
it said that when I success create/adding an event, youtube will returns url like this
<yt:cdn name='primary'>
<media:content yt:format='19' yt:name='yt-live_SpQXZYILnN0_35'
url='rtmp://rtmp1.youtube.com/videolive?...'/>
</yt:cdn>
but in my case, my returned data doesn't include this line
After do some research, I solved it by sending this request
/feeds/api/users/default/live/events?inline=true
and the youtube returns me RTMP server URL
Thanks all

Intuit anywhere API telling me that a field is required when it's already specified

I am trying to create an invoice in QB for windows. Here is the XML:
<?xml version='1.0' encoding='utf-8'?>
<Add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.intuit.com/sb/cdm/v2" xsi:schemaLocation="http://www.intuit.com/sb/cdm/V2./RestDataFilter.xsd " RequestId="1836474224e142c9ad9b7dd6cb0eaa41" FullResponse="true">
<OfferingId>ipp</OfferingId>
<ExternalRealmId>596059545</ExternalRealmId>
<Invoice>
<Header>
<TxnDate>2013-01-30</TxnDate>
<DiscountAmt>0</DiscountAmt>
<ARAccountName>Sales - Support and Maintenance</ARAccountName>
<DiscountAccountName>Discounts/Refunds</DiscountAccountName>
<DueDate>2013-02-17</DueDate>
<Currency>USD</Currency>
<CustomerId>4</CustomerId>
</Header>
<Line>
<Qty>1</Qty>
<UnitPrice>7.00</UnitPrice>
<Desc>Follow-up Test, Instant for Person138-Org3 Person138-Org3</Desc>
</Line>
</Invoice>
</Add>
Here's the response:
-2001: cvc-complex-type.2.4.a: Invalid content was found starting with element 'ARAccountName'. One of '{"http://www.intuit.com/sb/cdm/v2":DiscountAccountId, "http://www.intuit.com/sb/cdm/v2":DiscountAccountName, "http://www.intuit.com/sb/cdm/v2":DiscountTaxable, "http://www.intuit.com/sb/cdm/v2":TxnId}' is expected.
I don't understand, as I already have DiscountAccountName specified. I also tried to go with something more like the create example (same as above but with ARAccountName and DiscountAccountName removed) and got a similar response. Thanks in advance for your help.
The Intuit XML requests are validated by an XSD, and with XML validated by XSDs the order of the tags you provide matters.
That means that if the documentation (https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0600_Object_Reference/Invoice) dictates that ARAccountName comes before DiscountAmt, then you must put ARAccountName before DiscountAmt.
Switch the order of your XML tags to match the order shown in the docs, and you'll be all set.

Trouble getting a YQL table working

So I'm trying to set up a YQL table using the API at http://www.teamliquid.net/video/streams/?filter=live&xml=1 but having some issues.
Here's my table definition:
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>TL.net</author>
<description>TL.net's streams</description>
<documentationURL>none</documentationURL>
<sampleQuery>select * from {table}</sampleQuery>
</meta>
<bindings>
<select itemPath="streamlist" produces="XML">
<urls>
<url>http://www.teamliquid.net/video/streams/?xml=1</url>
</urls>
<inputs>
<key id="filter" type="xs:string" paramType="query" />
</inputs>
</select>
</bindings>
</table>
Running use "store://q5awkFLmEqteFVOTUJbQ6h" as tl; select * from tl where filter="live" yields the following error:
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="0" yahoo:created="2012-02-13T22:14:48Z" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
<url execution-start-time="1" execution-stop-time="33"
execution-time="32" proxy="DEFAULT"><![CDATA[store://q5awkFLmEqteFVOTUJbQ6h]]></url>
<url execution-start-time="35" execution-stop-time="232"
execution-time="197" http-status-code="406"
http-status-message="Not Acceptable" proxy="DEFAULT"><![CDATA[http://www.teamliquid.net/video/streams/?xml=1&filter=live]]></url>
<user-time>232</user-time>
<service-time>258</service-time>
<build-version>25247</build-version>
</diagnostics>
<results/>
</query>
I really can't figure out why it's not working.
In the debug statements, you can see that YQL is reading from your source URL: http://www.teamliquid.net/video/streams/?xml=1&filter=live, but is receiving back an HTTP 406 Not Acceptable error message.
HTTP 406 is meant to cover cases where the server cannot respond in any of the requested (Accept header) formats. I don't know how that applies in this case, but the teamliquid.net source mentions the following:
gzip encoding is required, please also send a valid User-Agent with the name of your application / site and contact info. This page and the XML are updated every five minutes, please do not poll more frequently than every five minutes or you may risk being IP banned. If you have any questions, please PM R1CH.
I suspect it's one of two things:
The YQL servers are not requesting data in gzip or compressed format
The teamliquid.net servers are blocking YQL

Resources