Step 6: Run (Part 2)#
Run Your Local Web Server#
Open a terminal window.
Enter Your Client Credentials#
Export your registered client credentials (see the Prereqisites) as environment variables.
Warning
Safeguard your Client ID and Client Secret values. Do not share these with any third parties as anyone with your Client ID and Client Secret values can impersonate you and act fully on your behalf.
Identity Provider (the IDP with whom you registered your application):
read -s MY_SOLID_IDP && export MY_SOLID_IDP
Enter
https://login.inrupt.com
Client ID:
read -s MY_SOLID_CLIENT_ID && export MY_SOLID_CLIENT_ID
Enter your Client ID.
Client Secret:
read -s MY_SOLID_CLIENT_SECRET && export MY_SOLID_CLIENT_SECRET
Enter your Client Secret.
Authentication Flow Method:
read -s MY_AUTH_FLOW && export MY_AUTH_FLOW
Enter
client_secret_basic
Run the Application#
Once you have entered your client credentials, start your application.
From your project (getting-started/
) directory, run your Spring
Boot application:
For Java, this tutorial assumes a Spring Boot Web Maven Project.
For Kotlin, this tutorial assumes a Spring Boot Web Gradle Project.
./mvnw spring-boot:run
./gradlew bootRun
Your Web service runs on http://localhost:8080
.
Reminder
The application is running as you, the user who registered it.
Test the Service#
Open another terminal window. To test, call the new endpoints
defined in the ExpenseController
class:
Endpoint |
Description |
---|---|
|
Saves a non-RDF resource, namely an image file of a receipt, to a location in the Pod and updates the expense with the receipt location. |
|
Saves a non-RDF resource to a location in the Pod. |
Get Pod URL#
To find your Pod URL, issue the following curl
command,
substituting your WebID (e.g., https://id.inrupt.com/yourUserName
):
curl -X GET http://localhost:8080/api/pods\?webid\=SUBSTITUTE_YOUR_WEBID
Upon success, the operation should return an array with your Pod Root URL; for example:
["https://storage.inrupt.com/00000000-your-pod-identifier/"]
Add a Receipt to Existing Expense#
To add a receipt to an existing expense created in Part 1, call the
api/expenses/receipts/add
endpoint with a local .png
file (can
be a different file type .jpg
, .pdf
, etc. as well),
substituting your Pod Root in the request body:
curl -X PUT http://localhost:8080/api/expenses/receipts/add \
-H "Content-Type: multipart/form-data" \
-F "destinationURL=https://storage.inrupt.com/00000000-your-pod-identifier/expenses/20230315/receipt.png" \
-F "file=@/my/local/file/path/to/receipt.png" \
-F "expenseURL=https://storage.inrupt.com/00000000-your-pod-identifier/expenses/20230315/expense1"
Upon success, the operation should return the content of the resource, formatted in Turtle:
<https://storage.inrupt.com/00000000-your-pod-identifier/expenses/20230315/expense1>
a <https://schema.org/Invoice> ;
<https://schema.org/purchaseDate>
"2023-03-06T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
<https://schema.org/category> "Travel & Entertainment" ;
<https://schema.org/description>
"Team Lunch" ;
<https://schema.org/image> <https://storage.inrupt.com/00000000-your-pod-identifier/expenses/20230315/receipt.png> ;
<https://schema.org/priceCurrency>
"USD" ;
<https://schema.org/provider> "Example Restaurant" ;
<https://schema.org/totalPrice>
"100"^^<http://www.w3.org/2001/XMLSchema#decimal> .
Save a Non-RDF File#
To save a receipt (a non-RDF resource) to your Pod, issue the following
curl
command to the api/resource/nonRDF/add
endpoint, substituting your Pod
Root in the request body:
curl -X PUT http://localhost:8080/api/resource/nonRDF/add \
-H "Content-Type: multipart/form-data" \
-F "destinationURL=https://storage.inrupt.com/00000000-your-pod-identifier/expenses/20230327/receipt.png" \
-F "file=@/my/local/file/path/to/newreceipt.png"
Upon success, the operation returns true
.
Create an Expense Record#
Using the receipt saved in the Save a Non-RDF File section, create a new expense that includes the receipt info, substituting your Pod Root in the request body:
curl -X POST http://localhost:8080/api/expenses/create \
-H 'Content-type:application/json' \
-d '{
"identifier": "https://storage.inrupt.com/00000000-your-pod-identifier/expenses/20230327/expense1",
"merchantProvider": "Example Supply Store",
"description": "Chair",
"expenseDate": "2023-03-27",
"amount": 400,
"currency": "USD",
"category": "Office Equipment & Supplies",
"receipts": [ "https://storage.inrupt.com/00000000-your-pod-identifier/expenses/20230327/receipt.png"] }'
Upon success, the operation returns the following:
<https://storage.inrupt.com/00000000-your-pod-identifier/expenses/20230327/expense1>
a <https://schema.org/Invoice> ;
<https://schema.org/purchaseDate>
"2023-03-27T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
<https://schema.org/category> "Office Equipment & Supplies" ;
<https://schema.org/description>
"Chair" ;
<https://schema.org/image> <https://storage.inrupt.com/00000000-your-pod-identifier/expenses/20230327/receipt.png> ;
<https://schema.org/priceCurrency>
"USD" ;
<https://schema.org/provider> "Example Supply Store" ;
<https://schema.org/totalPrice>
"400"^^<http://www.w3.org/2001/XMLSchema#decimal> .