0

I have question, i want to send data from my PC (windows) to Data base (back4app.com). For this i have possibility to use API request with cURL. My code to save data in DB:

curl -X POST -d @testFile.txt \
-H "X-Parse-Application-Id: MY_KEY" \
-H "X-Parse-REST-API-Key: API_KEY" \
https://parseapi.back4app.com/classes/check

In my testFile.txt i have such data:

Text=TextLable&body=checkSaving2&data=20.12.2017
Text=TextLable&body=checkSaving2&data=20.12.2017
Text=TextLable&body=checkSaving2&data=20.12.2017
Text=TextLable&body=checkSaving2&data=20.12.2017
Text=TextLable&body=checkSaving2&data=20.12.2017
Text=TextLable&body=checkSaving2&data=20.12.2017
Text=TextLable&body=checkSaving2&data=20.12.2017
Text=TextLable&body=checkSaving2&data=20.12.2017

And in my DB i receive all data in one column:

1

But i need each row in each column. EX:

Column - Text:  Column - body:   Column - data:
TextLable       checkSaving2.     20.12.2017 
TextLable       checkSaving2.     20.12.2017 
TextLable       checkSaving2.     20.12.2017 
TextLable       checkSaving2.     20.12.2017 
TextLable       checkSaving2.     20.12.2017 

So, how i can do like upper example, to save my data in DB

Andrew
  • 572
  • 6
  • 29
  • What does this have to do with batch files? – DavidPostill Apr 02 '18 at 09:02
  • Maybe somebody have alternative with batch file – Andrew Apr 02 '18 at 09:26
  • Yes, but - please note that https://stackoverflow.com is not a free script/code writing service. If you tell us what you have tried so far (include the scripts/code you are already using) and where you are stuck then we can try to help with specific problems. You should also read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). – DavidPostill Apr 02 '18 at 09:39

1 Answers1

1

I am guessing you are looking for Parse batch operations.

To reduce the amount of time spent on network round trips, you can create, update, or delete up to 50 objects in one call, using the batch endpoint.

Using batch operations you can embed many parse api requests in one http request. For example:

curl -X POST \
  -H "X-Parse-Application-Id: ${APPLICATION_ID}" \
  -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
        "requests": [
          {
            "method": "POST",
            "path": "/parse/classes/check",
            "body": {
                "body": "checkSaving2",
                "data": "20.2.2017"
            }
          },
          {
            "method": "POST",
            "path": "/parse/classes/check",
            "body": {
              "body": "checkSaving2",
              "data": "20.2.2017"

            }
          }
        ]
      }' \
  https://YOUR.PARSE-SERVER.HERE/parse/batch

Read more here: http://docs.parseplatform.org/rest/guide/#batch-operations

Alternatively, you could just add one object in each cURL request and wrap it with a for loop to make it add many objects.

Gal
  • 141
  • 8