Strapi post request with relation - axios

I'm trying to do a POST to the Strapi API and can't seem to figure out how to attach a 'has and belongs to one' (one to one) relationship from the profile to the user.
I know the relationship works well because in the admin panel I can create the relationship without any problem
I've already tried the following body's:
{
"fullName":"Test Name",
"country": "Nigeria",
"phone": "09070933598",
"verified": true,
"users_permissions_user": {
"id": 22
}
}
I got this response
{
"id": 3,
"users_permissions_user": {},
"fullName": "Test Name",
"country": "Nigeria",
"verified": true,
"plan": null,
"earnings": 0,
"availableBalance": 0,
"planRegDate": null,
"planActive": false,
"planPaymentVerified": false,
"phone": "09070933598",
"published_at": "2021-10-19T08:43:04.412Z",
"created_at": "2021-10-19T08:43:04.428Z",
"updated_at": "2021-10-19T08:43:04.470Z",
"identification": null
}
I expect to at least have some info about the user with the id passed in the body. It isn't just linking them

You need to pass the id of one of the users already in your strapi database to "users_permissions_users".
You can get this from the user object.
{
"fullName":"Test Name",
"country": "Nigeria",
"phone": "09070933598",
"verified": true,
"users_permissions_user": user.id
}

Related

Posting address to Sharepoint list via REST

maybe I'm blind but I can't find a documentation how I post an address to an address field on a Sharepoint list via REST.
I always receive an "invalid Request" error. If I remove the address part of my JSON I'm able to fill out the other fields w/o problems. Just struggling with the address.
My request looks like that:
POST:
https://graph.microsoft.com/v1.0/sites/test.sharepoint.com,{siteid}/lists/{listid}/items/
Data:
{
"__metadata": {
"type": "SP.Data.listname.ListItem"
},
"fields":{
"Title": "API Test Project",
"Projekt_ID": "25",
"Typ": "HinzugefĆ¼gt",
"MengeNeu": "50/40/330",
"PosNr": "5/4/1",
"Adresse": {
"address": {
"city": "city",
"countryOrRegion": "DE",
"postalCode": "55512",
"state": "test",
"street": "test street 3"
},
"coordinates": {
"latitude": 44.72789001464844,
"longitude": 10.132317543029785
},
"displayName": "Test",
"locationUri": "https://www.bingapis.com/api/v6/localbusinesses/xxx?setLang=de",
"uniqueId": "https://www.bingapis.com/api/v6/localbusinesses/xxx?setLang=de"
}
}
}
Thanks

Trying to figure out how tax lines work when creating Shopify order via API

I am posting the following to the Shopify API create order endpoint and receiving a response without tax lines that are filled. I haven't seen anything on the internet on this, other than that Shopify doesn't offer another endpoint for just taxes. So, I am trying to figure out if tax lines are supposed to be generated automatically in the order response when creating an order via the API or if I have to include the tax lines in the request in order for tax lines to be included, because I know when I create an order in the admin the tax lines are automatically calculated and included for me?:
{
"order": {
"email": "some#email.com",
"financial_status": "paid",
"fulfillment_status": null,
"send_receipt": true,
"send_fulfillment_receipt": true,
"note": "Created by somename",
"line_items": [
{
"variant_id": 21718275463,
"quantity": 1,
"price": 99,
"requires_shipping": true,
"product_id": 6820646151
},
{
"variant_id": 21717700871,
"quantity": 1,
"price": 1000,
"requires_shipping": true,
"product_id": 6820646151
},
{
"variant_id": 21717690055,
"quantity": 1,
"price": 555,
"requires_shipping": true,
"product_id": 6821668807
}
],
"processing_method": "offsite",
"shipping_address": {
"first_name": "Chris",
"address1": "10101 Musick Road",
"phone": "9999999999",
"city": "St. Louis",
"zip": "63123",
"province": "MO",
"country": "United States",
"last_name": "Becker",
"name": "Chris Becker",
"country_code": "US",
"province_code": "MO"
},
"source_name": "somename",
"taxes_included": false,
"shipping_lines": [
{
"title": "standard",
"price": 0.00,
"code": null,
"source": "brand owner on shopify",
"carrier_identifier": null,
"tax_lines": null
}
],
"tags": "some Order"
}
}
Here is a useful documentation about tax: https://help.shopify.com/api/reference/location
Tax are not automatically calculated from cart.js ajax api. They just give a clue whether tax is already included in the price or not. If not, then it can be added with the bill.

Jasper Report with RestAPI

I have a report on JasperServer(5.6) which accepts few parameters. I edit few settings on the Output Options tab and enter emails which i would like to sent to on Notifications tab. The report gets generated successfully and an email is sent out perfectly.
I wish to use the Rest API of JasperServer to pass on my input options and to schedule and email the report. I went through there documentation http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v56/rest-v2-report-services but couldn't understand how to use the rest api.
Here is the properties of my report on the jasper server
Can someone help me out how to schedule my report.
Maybe it's can help you: jasperserver rest java client.
This is a REST client for Jasperserver.
I guess, i have figured out the way to schedule a job on jasper server. Details can be found here
http://community.jaspersoft.com/documentation/tibco-jasperreports-server-web-services-guide/v62/scheduling-report
But as an example here it is (call it with PUT method)
http://localhost:8080/jasperserver/rest_v2/jobs
and in the body define the job structure
{
"id": 3819,
"version": 2,
"username": "jasperadmin",
"label": "publisher_123_report",
"description": "",
"creationDate": "2015-12-30T02:02:40.382+03:00",
"trigger": {
"simpleTrigger": {
"id": "1770",
"misfireInstruction": "0",
"startDate": "2015-12-20T00:00:00+11:00",
"startType": "2",
"timezone": "Australia/Victoria",
"version": "0",
"occurrenceCount": "1"
}
},
"source": {
"reportUnitURI": "/Reports/Prod/test_automated_report_v14",
"parameters": {
"parameterValues": {
"PublisherId" : "20",
"MonthEnd" : "2015-02-01",
"MonthStart" : "2015-03-20",
"email" : "admin#admin.com",
"CountryCode" : "560"
}
}
},
"baseOutputFilename": "publisher_124_automated_report",
"outputLocale": "",
"mailNotification": {
"subject": "publisher monthly report" ,
"toAddresses": {
"address": ["address1To#add.com", "address2To#add.com"]
},
"ccAddresses": {
"address": ["address1cc#add.com", "address2cc#add.com"]
},
"bccAddresses": {
"address": ["address1bcc#add.com", "address2bcc#add.com"]
},
"includingStackTraceWhenJobFails" : false,
"resultSendType" : "SEND_EMBED",
"skipEmptyReports" : true,
"skipNotificationWhenJobFails" : false
},
"alert": {
"id": 0,
"version": -1,
"recipient": "OWNER_AND_ADMIN",
"toAddresses": {
"address": ["address1#add.com", "address2#add.com"]
},
"jobState": "FAIL_ONLY",
"messageText": "Success",
"messageTextWhenJobFails": "Failure",
"subject": "Notification Subject",
"includingStackTrace": true,
"includingReportJobInfo": true,
"jobState" : "ALL"
},
"outputTimeZone": "Australia/Melbourne",
"repositoryDestination": {
"id": 3817,
"version": 0,
"folderURI": "/Reports/Prod",
"sequentialFilenames": false,
"overwriteFiles": false,
"outputDescription": "",
"timestampPattern": null,
"saveToRepository": true,
"defaultReportOutputFolderURI": null,
"usingDefaultReportOutputFolderURI": false,
"outputLocalFolder": null,
"outputFTPInfo": {
"userName": null,
"password": null,
"folderPath": null,
"serverName": null
}
},
"outputFormats": {
"outputFormat": ["HTML"]
}
}
More options can be supplied while the creating job.

Get list of related tracks HTTP API SoundCloud

I wasn't able to find anything fitting in HTTP API documentation.
As I know, there's some tracks popping out in SC widget after current track is finished, therefore there is some related tracks functionality in SC itself, yet can we access it via API?
I.e get a list of tracks, related to given track's id.
Disclaimer: This is an undocumented endpoint and is subject to change at anytime by SoundCloud.
There is an undocumented endpoint that allows you to access a track's related sounds:
HTTP GET: https://api.soundcloud.com/tracks/[TRACK_ID]/related?client_id=[YOUR_CLIENT_ID]
You didn't specify a language, so i'm just going to give a high-level overview on how to use the endpoint.
First, get your track URL. I'll use this one as an example: https://soundcloud.com/msmrsounds/ms-mr-hurricane-chvrches-remix
Then hit the resolve endpoint to get the track_id.
HTTP GET: https://api.soundcloud.com/resolve.json?url=https%3A%2F%2Fsoundcloud.com%2Fmsmrsounds%2Fms-mr-hurricane-chvrches-remix&client_id=[YOUR_CLIENT_ID]
Response:
{
"status": "302 - Found",
"location": "https://api.soundcloud.com/tracks/90787841.json?client_id=[YOUR_CLIENT_ID]"
}
Next, hit the related endpoint with your track_id.
HTTP GET: https://api.soundcloud.com/tracks/90787841/related?client_id=[YOUR_ClIENT_ID]
The full response will give you up to 50 related tracks. The response is too large to post, but it's just an array of tracks.
[
{
"kind": "track",
"id": 112741336,
"created_at": "2013/09/27 09:40:29 +0000",
"user_id": 59817646,
"duration": 215896,
"commentable": true,
"state": "finished",
"original_content_size": 38068298,
"last_modified": "2015/04/04 20:17:24 +0000",
"sharing": "public",
"tag_list": "CHVRCHES Whitney Houston Zane Lowe",
"permalink": "chvrches-its-not-right-but-its",
"streamable": true,
"embeddable_by": "all",
"downloadable": false,
"purchase_url": null,
"label_id": null,
"purchase_title": null,
"genre": "Electronic",
"title": "CHVRCHES - It's Not Right But It's Okay (Whitney Houston Cover)",
"description": "CHVRCHES - It's Not Right But It's OK (Whitney Houston Cover) from Zane's Live Sessions",
"label_name": "",
"release": "",
"track_type": "recording",
"key_signature": "",
"isrc": "",
"video_url": null,
"bpm": null,
"release_year": null,
"release_month": null,
"release_day": null,
"original_format": "wav",
"license": "all-rights-reserved",
"uri": "https://api.soundcloud.com/tracks/112741336",
"user": {
"id": 59817646,
"kind": "user",
"permalink": "uknewmusic",
"username": "UKNewMusic",
"last_modified": "2013/09/27 09:38:04 +0000",
"uri": "https://api.soundcloud.com/users/59817646",
"permalink_url": "http://soundcloud.com/uknewmusic",
"avatar_url": "https://a1.sndcdn.com/images/default_avatar_large.png"
},
"permalink_url": "http://soundcloud.com/uknewmusic/chvrches-its-not-right-but-its",
"artwork_url": "https://i1.sndcdn.com/artworks-000058757165-6tnuep-large.jpg",
"waveform_url": "https://w1.sndcdn.com/XkEffI5hwjZ7_m.png",
"stream_url": "https://api.soundcloud.com/tracks/112741336/stream",
"playback_count": 680326,
"download_count": 0,
"favoritings_count": 9241,
"comment_count": 199,
"attachments_uri": "https://api.soundcloud.com/tracks/112741336/attachments",
"policy": "ALLOW"
},
{ ...
}
]

How to Set Venue for Event using Graph API

When I create events, I've tried adding venue details similar to what it looks like below, but the venue information seems to be ignored. (I'm posting it to /me/events)
The event otherwise gets created successfully. How can I set the venue during the creation process? Do I need to create it afterwards instead? Thanks
{
"owner": {
"name": "David R",
"id": "234234"
},
"name": "sdf",
"description": "tes",
"start_time": "2011-09-11T00:00:00",
"end_time": "2011-09-11T03:00:00",
"location": "sadf",
"venue": {
"street": "weber",
"city": "Waterloo",
"state": "Ontario",
"country": "Canada"
},
"privacy": "SECRET",
"updated_time": "2011-09-10T23:22:23+0000",
"type": "event"
}
get rid of '"venue"{}' and just use city state country etc..
{'name':"neverland",
'city':"los angeles",
'description':"ontherparty",
'location':"sames",
'start_time': "9-12-2011 12:45"
}