Trying to add a column to a Google Fusion table and keep on getting "NOT FOUND" error message.
Sub to Add Column:
Because the post request requires headers I added two new subs into HttpJob. I pass a Map of the header values and the use SetHeader to set the values.
I know the table exists because I cut and pasted into https://developers.google.com/fusiontables/docs/v1/reference/column/insert Try it section at the bottom and that gives me the following post request:
I know my Auth key is ok because I just used it to get a list of tables. I really can't work out where I am going wrong.
Sub to Add Column:
B4X:
Sub InsertColumn(oReturnObject As Object,cReturnSub As String,cTableName As String,cColumnName As String,cColumnType As String)
Dim oTableToAddColumnTo As FusionTable
Dim oJSONGenerator As JSONGenerator
Dim mColumnMap As Map
Dim oCallBack As CallBackClass
Dim cColumnLink As String
Dim cPostString As String
Dim oHttpJob As HttpJob
Dim oStringUtils As StringUtils
Dim mHeaders As Map
mHeaders.Initialize
mColumnMap.Initialize
If mTables.ContainsKey(cTableName) Then
oCallBack.Initialize(oReturnObject,cReturnSub,"")
oTableToAddColumnTo = mTables.Get(cTableName)
mColumnMap.Put("Name",cColumnName)
mColumnMap.Put("Type",cColumnType)
oJSONGenerator.Initialize(mColumnMap)
mJobMap.Put("InsertColumn",oCallBack)
cColumnLink = cTableLink & "/" & oTableToAddColumnTo.fusTableId & "/coulmns?key=" & CMyApiKey
cPostString = oJSONGenerator.ToString
mHeaders.Put("Authorization",cAuthToken)
mHeaders.Put("Content-Type","application/json")
oHttpJob.Initialize("InsertColumn",Me)
Log(cColumnLink)
Log(cPostString)
oHttpJob.PostString2(cColumnLink,cPostString,mHeaders)
End If
End Sub
Because the post request requires headers I added two new subs into HttpJob. I pass a Map of the header values and the use SetHeader to set the values.
B4X:
Public Sub PostString2(Link As String, Text As String,mHeaders As Map)
PostBytes2(Link, Text.GetBytes("UTF8"),mHeaders)
End Sub
Public Sub PostBytes2(Link As String, Data() As Byte,mHeaders As Map)
Dim cKeys As String
mLink = Link
req.InitializePost2(Link, Data)
For Each cKey In mHeaders.Keys
If cKey = "Content-Type" Then
req.SetContentType(mHeaders.Get(cKey))
Else
req.SetHeader(cKey,mHeaders.Get(cKey))
End If
Next
CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)
End Sub
I know the table exists because I cut and pasted into https://developers.google.com/fusiontables/docs/v1/reference/column/insert Try it section at the bottom and that gives me the following post request:
B4X:
POST https://www.googleapis.com/fusiontables/v1/tables/1JBBxm7njSjzSP--pXBDsz5PpoYUgn0Zl4ufNmyE/columns?key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer ya29.AHES6ZTAg8DmbmjZx98_oVsKuIrML_qgzZh0JJp_zrgEBIZHoMbmZhM
X-JavaScript-User-Agent: Google APIs Explorer
{
"name": "test",
"type": "STRING"
}
I know my Auth key is ok because I just used it to get a list of tables. I really can't work out where I am going wrong.