How to upload user picture in moodle from other system using web service - moodle

I have Moodle & Drupal integrated system, Drupal is primary, user is created in drupal first then it will create in moodle via web services, but I am not able to carry user picture from drupal to moodle, I don't want core fixes, need clean and systematically solution for it.
Can anyone help me?

Unfortunately there isn't an appropriate web service in core which supports this at the moment. You can see web services documented in your Moodle install in Home ▶ Site administration ▶ Plugins ▶ Web services ▶ API Documentation.
There are many ways to support this with plugins, but since you do not seem keen to go down this route, have your considered using Gravatar as a solution? There are docs on how to set this up: http://docs.moodle.org/25/en/Roles_settings#Enable_Gravatar

the first step upload the picture
localhost/moodle/webservice/upload.phptoken=9f47591ed3f6cc53720f0dc4e81&filearea=draft
Params:-
token=9f47591ed3f6cc53720f0dc4e81
filearea=draft
then you will get a response like
[
{
"component": "user",
"contextid": 5,
"userid": "2",
"filearea": "draft",
"filename": "Ali Hasans Resume.pdf",
"filepath": "/",
"itemid": 560134043,
"license": "unknown",
"author": "Admin User",
"source": "O:8:\"stdClass\":1:{s:6:\"source\";s:21:\"Ali Hasans Resume.pdf\";}"
}
]
second step
update the profile picture
localhost/moodle/webservice/rest/server.php?moodlewsrestformat=json&draftitemid=560134043&wsfunction=core_user_update_picture&wstoken=9f47591ed3f6cc53720f0dc4e81
params
moodlewsrestformat=json
draftitemid=560134043 this "draftitemid" comes from upload.php response
wsfunction=core_user_update_picture
wstoken=9f47591ed3f6cc53720f0dc4e81
if it's a success then the response will like
{
"success": true,
"profileimageurl": "http://localhost/moodle/theme/image.php/alpha/core/1609845491/u/f1",
"warnings": []
}
here I get this idea https://tracker.moodle.org/browse/MDL-56070

Related

How to log with Serilog to a remote server?

I'm writing a .NET Core 6 Web API and decided to use Serilog for logging.
This is how I configured it in appsettings.json:
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Information"
},
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "../logs/webapi-.log",
"rollingInterval": "Day",
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} {CorrelationId} {Level:u3}] {Username} {Message:lj}{NewLine}{Exception}"
}
}
]
}
This is working fine, it's logging inside a logs folder in the root.
Now I've deployed my API to a Staging K8s cluster and don't want my logs to be stored on the pod but rather on the Staging server. Is it possible? I can't find many useful posts about it, so I assume there is a better way to achieve it.
Based on Panagiotis' 2nd suggestion I spent like a week to try to set up Elasticsearch with Fluentd and Kibana with no success.
Turned out, that the simplest and easiest solution was his 1st one: all I needed was a PersistentVolume and a PersistentVolumeClaim. This post helped me with the setup: How to store my pod logs in a persistent storage?

Swift Package Collections doesn't work with an Entreprise GitHub account

I am trying to generate a package collections from a GitHub entreprise account, using the command line (follwing the steps on the official doc):
package-collection-generate packages.json collection.json
When I ran this command, the Terminal ask me for my user name, once provided it keeps runing without a result, until I stop it using Ctl-C
The packages.json looks like this:
{
"name": "Entreprise iOS packages",
"overview": "This collection contains the entreprise Swift packages.",
"author": {
"name": "Swift packages"
},
"keywords": [
"iOS"
],
"packages": [
{
"url": "https://github.entreprise.com/[ORGANISATION]/[REPO].git"
}
]
}
I have also ttried to integrate my access token and user name in the url like this:
https://[UserName]:[AccessToken]#https://github.entreprise.com/[ORGANISATION]/[REPO].git
I have also tried to use the SSH url, with no success.
git#github.entreprise.com:[ORGANISATION]/[REPO].git
I can import the same package using Xcode Packages
I have SSH configured on my machine
I have tried to use both Private and Public access to the repo
With the same setup, I can create a collection using a non-entreprise GitHub account.
Maybe I am missing something or Swift Package Collection doesn't work with a GitHub Entreprise account!
Can you please advice what to do here?
You talk about a Github enterprise account but give a completely wrong URL in multiple places in your question (including your packages.json). Double-check that.

Extending S/4HANA OData service to SCP

I want to extend a custom OData service created in a S/4HANA system. I added a Cloud Connector to my machine, but I don't know how to go from there. The idea is that I want people to access the service from SCP and that I don't need multiple accounts accessing the service on the S/4 system, but just the one coming from SCP. Any ideas?
Ok I feel silly doing this but it seems to work. My test is actually inconclusive because I don't have a cloud connector handy, but it works proxy-ing google.
I'm still thinking about how to make it publicly accessible. There might be people with better answers than this.
create the cloud connector destination.
make a new folder in webide
create file neo-app.json.
content:
{
"routes": [{
"path": "/google",
"target": {
"type": "destination",
"name": "google"
},
"description": "google"
}],
"sendWelcomeFileRedirect": false
}
path is the proxy in your app, so myapp.scp-account/google here. the target name is your destination. I called it just google, you'll put your cloud connector destination.
Deploy.
My test app with destination google going to https://www.google.com came out looking like this. Paths are relative so it doesn't work but google seems proxied.
You'll still have to authenticate etc.

Failed to load resource while consuming OData service

Hello comunnity i need some help, i have my odata service already running and i have an url like this:
https://myclient:port/sap/opu/odata/SAP/servicename_SRV/MaterialListSet
This is my config, which I suppose is wrong.
manifest.json
"dataSources": {
"invoiceRemote": {
"uri": "https://myclient:port/sap/opu/odata/SAP/servicename_SRV/",
"type": "OData",
"settings": {
"odataVersion": "2.0"
}
}
}
.
.
.
"models": {
...
"invoice": {
"dataSource": "invoiceRemote"
}
}
I get these two errors:
Failed to load resource: the server responded with a status of 401 (Unauthorized)
and
Failed to load https://client:port/sap/opu/odata/SAP/odata_SRV/$metadata?sap-language=ES: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:port' is therefore not allowed access. The response had HTTP status code 401.
This line is not good;
"uri": "https://myclient:port/sap/opu/odata/SAP/servicename_SRV/",
This is because you have to use relative URLs, so it should be
"uri": "/sap/opu/odata/SAP/servicename_SRV/",
The reason behind that is simple: your customer for sure has more than one SAP Gateway/Fiori system. So you shouldn't hard code the domain of your development or production system.
Assuming you will eventually deploy your UI5 application to the SAP NetWeaver system, then that system will contain both the oData service AND the UI5 application. And as they will be hosted in the same server, relative URLs will work just fine.
However inside Web IDE this is not enough because if you use relative URLs than SAP Cloud/Web IDE will understand that you are trying to access a resource in the cloud.
That is why you should add/change your neo-app.json file inside your UI5 project. If you have it already than just change it. If you do not have this file inside your project yet, you can easily create it by right-clicking in the project name and choosing New >> HTML5 Application Descriptor. This will create this file in the root of your project. (outside the webapp folder usually present).
Finally, you will have to add a route in this neo-app.json file, like this
{
"path": "/sap/opu/odata",
"target": {
"type": "destination",
"name": "NAME_OF_YOUR_SAP_CLOUD_DESTINATION",
"entryPath": "/sap/opu/odata"
},
"description": "SAP Gateway System"
}
This tells Web IDE to forward every request to a different system under the destionation specified.
This will only work if you have in place an SAP Cloud Connector linking your SAP Cloud account with your SAP NetWeaver on premise system.

IBM Watson Natural Language Understanding error "attempt to fetch failed: :closed

I'm trying to test a site out using the IBM Watson Natural Language Understanding service. I'm doing so using this tool (https://natural-language-understanding-demo.mybluemix.net/) and entering a URL from our site to test.
Using our production servers (https://www.knox.edu), I get the following error for every page of the site.
{code: 400, error: "attempt to fetch failed: :closed"}
Using a test server of the same site (https://cmstest.knox.edu/test), it all works fine though.
What would be causing the errors from our production server?
Thanks!
This error is typically caused by a site's robots.txt preventing the Watson NLU service from scraping the URL.
Check your robots.txt file to see if it's blocking user-agents (perhaps globally).
There's some additional info from a discussion of this error using the Python SDK here: https://github.com/watson-developer-cloud/python-sdk/issues/199
Looks like NLU has updated their crawling engine, the website you mentioned is crawlable from NLU now, when I ran categories call I am receiving the following output
{
"categories": [{
"score": 0.999469,
"label": "/education/graduate school/college"},{
"score": 0.497251,
"label": "/law, govt and politics/legal issues/legislation/tax laws},{
"score": 0.466882,
"label": "/travel/tourist destinations/africa"}]
}