Microsoft Graph POST New Row to Excel Table - microsoft-graph-api

I am trying to post a new row of data to an Excel table. I am sending a POST request to the Table / Rows. A new row is being added but with empty values. This happens both when I POST from code and also if I POST from the Microsoft Graph Explorer.
The POST statement I am using is:
POST /v1.0/drives/{driveid}/items/{itemid}/workbook/tables/{tableid}/rows
content-type: Application/Json
authorization: Bearer {access-token}
{
"value": [{
"values": [
["44444 : 22/08/2017 12:14:46",
"44444",
"22/08/2017 12:14:46",
"New Name",
"Status",
"01/10/2017 12:14:46",
"563",
"Filename"
]
],
"index": null
}]
}
I get a successful response message but with empty field values and the table has a blank row added.
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives({driveid)/items(itemid)/workbook/tables({tableid})/rows/$entity",
"#odata.id": "/drives({driveid})/items({itemid})/workbook/tables({tableid})/rows(null)",
"index": 2,
"values": [
[
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
]
]
}
How do I get the POST to include the values into the new row?

After more experimenting I have found what I have done wrong. My table has more columns in it than I was posting to. You need to post to all columns. I needed to add an additional two blank fields in this case. When the correct number of values was included the post works.

The JSON needs to be formatted like this as well as needing to have a value for each column in the table.
{ "values": [ [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29" ] ] }

Related

My EF Core 6 OData endpoint is returning whole infrastructure instead of model?

My EF Core application is returning what I imagine is context information in response instead of model. When calling the endpoint with expand option. This is the result returned:
{
"$id": "1",
"instance": null,
"container": {
"$id": "2",
"name": "SurveyQuestionValidations",
"value": null,
"next0": {
"$id": "3",
"name": "Id",
"value": 1,
"autoSelected": true
},
"autoSelected": false
},
"model": {
"$id": "4",
"schemaElements": [
{
"$id": "5",
"declaredKey": [
{
"$id": "6",
"defaultValueString": null,
"propertyKind": 1,
"type": {
"isNullable": false,
"definition": {
"$id": "7",
"name": "Int32",
"namespace": "Edm",
"typeKind": 1,
"primitiveKind": 9,
"schemaElementKind": 1,
"fullName": "Edm.Int32"
}
},
"declaringType": {
"$ref": "5"
},
"name": "Id"
}
],
"schemaElementKind": 1,
"namespace": "Data.Models",
"name": "SurveyQuestion",
"fullName": "Data.ModelsSurveyQuestion",
"typeKind": 2,
"hasStream": false,
"isAbstract": false,
"isOpen": false,
"declaredProperties": [ ...etc
This only happens when using expand. And the query is really slow but I believe it is related.

Postman - POST users into BIM 360 bug?

https://forge.autodesk.com/en/docs/bim360/v1/reference/http/users-POST/#example
Following the link above, I am trying to create a new user in BIM 360 using Postman but I am unable to set their name. I tried to create a similar user into my own account as shown below.
URI:
https://developer.api.autodesk.com/hq/v1/accounts/:account_id/users
Method: POST
Authorization: Bearer **************************
Content-Type: application/json
Body:
{
"email": "john.smith#mail.com",
"company_id": ************************************,
"nickname": "Johnny",
"first_name": "John",
"last_name": "Smith",
"address_line_1": "The Fifth Avenue",
"address_line_2": "#301",
"city": "shanghai",
"postal_code": "20000",
"state_or_province": "Shanghai",
"country": "China",
"phone": "1234567",
"company": "Autodesk",
"job_title": "software developer",
"industry": "IT",
"about_me": "Nothing here"
}
However the result when sending this request creates a new user with the name New Member as shown below.
{
"account_id": ************************************,
"role": "account_user",
"status": "not_invited",
"company_id": ************************************,
"company_name": "Autodesk",
"last_sign_in": null,
"default_role": null,
"default_role_id": null,
"access_level": "account_user",
"id": ************************************,
"email": "john.smith#mail.com",
"name": "New Member",
"nickname": "Johnny",
"first_name": "New",
"last_name": "Member",
"uid": null,
"image_url": "http://static-dc.autodesk.net/etc/designs/v201412151200/autodesk/adsk-design/images/autodesk_header_logo_140x23.png",
"address_line_1": "The Fifth Avenue",
"address_line_2": "#301",
"city": "New York",
"postal_code": "10011",
"state_or_province": "New York",
"country": "United States",
"phone": "(634)329-2353",
"company": "Autodesk",
"job_title": "Software Developer",
"industry": "IT",
"about_me": "Nothing here",
"created_at": "2016-07-27T19:09:31.998Z",
"updated_at": "2019-02-19T08:59:57.852Z"
}
Is this a bug? When I check BIM 360 the user is created with the name New Member and I am unable to create any members with my own custom names. Are there any solutions to this?
The name attribute will not be synced between BIM360 and Identity services until the user logs in for the first time.
Before then name won’t be set and will default to New Member.

Post Data Into this type of format?

I am not getting how to POST this type of data into webservice
{
"customer_id":"",
"customer_message": " entered by user",
"discount_amount": "",
"ip_address":"1.0.10.22",
"billing_address": {
"first_name": "hello",
"last_name": "world",
"company": "",
"street_1": "45 W test",
"street_2": "",
"city": "London",
"state": "Texas",
"zip": "123456",
"country": "United States",
"country_iso2": "US",
"phone": "",
"email": "xyz#example.com"
},
"shipping_addresses": [
{
"first_name": "rest",
"last_name": "Mctest",
"company": "Test Address",
"street_1": "rest test",
"street_2": "",
"city": "test",
"state": "test",
"zip": "12345",
"country": "United States",
"country_iso2": "US",
"phone": "",
"email": "xyzer#example.com"
}
],
"products": [
{
"product_id": 5448,
"quantity": 2
}
]
I am not getting how to POST this type of data into webservice.
Please help me
i am doing this type of data now i have to post this type. Can anyone post this type.
let aParam = ["email": Email, "password":Password] as [String:Any]
You are taking parameters as [String: Any], where Any denotes each type of data types. Say String, Array and Dictionary.
For example,
let aParam: [String: Any] = ["customer_id": "",
"customer_message": "",
"billing_address": ["first_name" : "hello",
"last_name" : "world",
"company" : "",
"street_1" : "45 W test"],
"shipping_addresses": [
["first_name" : "hello",
"last_name" : "world",
"company" : "",
"street_1" : "45 W test"]
],
"products": [
["product_id" : 5448,
"quantity" : 2],
["product_id" : 5450,
"quantity" : 1]
]
]
And complex json structure would be handle with content-type as JSON, so:
You just need to update your header as:
let aHeader = ["Content-Type" : "application/json"]
Hope this will help

How to sort multidimensional array in swift?

I need your help. I did an array, and when I launch my application on different devices or simulator, this array sorted into different types, but I need the same order on each device. How to do that?
var settings = [String: [ [String: String] ]]()
settings = [ "cards":[ ], "groups":[ ] ]
...
for card in db.prepare(table.order(orderN.asc)) {
settings["cards"]?.append(["id":String(card[id]), "group_id":String(card[group_id]), "service":card[service], "bgcolor":card[bgcolor], "logoimg":card[logoimg]!, "balance_desc":card[balance_desc], "balance":"0.0", "balance_id":String(card[balance_id]), "uniqueID":card[uniqueID], "balance_currency":String(card[balance_currency]), "orderN":String(card[orderN])])
}
...
for group in db.prepare(table.order(orderN.asc)) {
settings["groups"]?.append(["name":group[name]!,"id":String(group[id]),"orderN":String(group[orderN])])
}
...
For example,
On the first device
print(settings) // ["cards": [["orderN": "0", "bgcolor": "0.0, 0.0, 0.0, 1.0", "balance": "0.0", "logoimg": "example.com/images/img.png", "uniqueID": "00a2413f74f4a3f186e439a67057de67", "group_id": "2", "id": "1", "service": "servicename", "balance_desc": "Description", "balance_id": "1", "balance_currency": "1"]], "groups": [["orderN": "0", "name": "GroupName", "id": "2"]]]
On the second device
print(settings) // ["cards": [["orderN": "0", "uniqueID": "00a2413f74f4a3f186e439a67057de67", "service": "servicename", "id": "1", "bgcolor": "0.0, 0.0, 0.0, 1.0", "balance_currency": "1", "balance": "0.0", "group_id": "2", "logoimg": "example.com/images/img.png", "balance_id": "1", "balance_desc": "Description"]], "groups": [["id": "2", "orderN": "0", "name": "GroupName"]]]
Thank you for you attention.
That's because settings is not an Array, it's Dictionary. Order of key-value pairs in dictionary is not defined.
If you need some particular order, you should reimplement settings, probably make them separate struct or class, because you'll have a hard time working with nested dictionaries.

How to combine hash with an array and display result as json

I'm trying to display a json after different SQL queries. Some of the SQL queries return one value but I got an array of results from one of the queries. You can see the example of the json that I want to show below.
{
"id": "4",
"potential": "23",
"conversion": "45",
"new": "34",
"repeat": "22",
"average": "14",
"traffic": [
{
"time": "9",
"new": "2",
"repeat": "1"
},
{
"time": "10",
"new": "6",
"repeat": "9"
}
]
}
I can display separately hash and array as json, however I can't combine them.
{
"id": "4",
"potential": "23",
"conversion": "45",
"new": "34",
"repeat": "22",
"average": "14"
}
AND
[
{
"time": 5,
"new": 0,
"repeat": 80
},
{
"time": 6,
"new": 1,
"repeat": 80
}
]
Any suggestions? Thank you
Traverse the response you get and add the data into a Hash. Here is a ruby-doc for it. If you need a bit idea of how to use hash see below code.
x = {"id" => "4", "potential" => "23","conversion"=> "45","new"=> "34","repeat"=> "22","average"=> "14"}
x["traffic"] =[{"time"=>5,"new"=>0,"repeat"=>80},{"time"=>6,"new"=>1,"repeat"=>80}]
You would have to use your logic to build the hash. I just wrote something for you. Also you can then return the hash by render :json => x.

Resources